Write for Android Analyse

Android Analyse

Filter Search

Only this category...

B4A: The other way to develop for Android

By Rodney - August 10, 2012 0

Android Analyse No comments yet

Xposing your Android’s powers

Android Analyse 2 comments

Android Studio 0.1.5 released, some bugs get squashed

Android Analyse 1 comment

greenDAO – Testing Migration

Android Analyse No comments yet

Jimu: Building blocks for Android apps needs your KickStarter support

Android Analyse 8 comments

greenDAO – Schema Migration

Android Analyse 2 comments

greenDAO – Schema Generation

Android Analyse 3 comments

Android Devs Making Waves: Expense Manager, Hashnote, Work Quietly and Notif

Android Analyse No comments yet

greenDAO – Version 1.3 released

B4A

So you’ve got a great idea for an app or you’d like to stretch the functionality of your phone a little further but you’ve just gone to the hello world post at Android.com and now you’re feeling like giving up?

Well, I’m here to tell you, you’re not alone. Developing an app for Android can be a daunting experience for the novice programmer and let’s face it – not everyone out there is comfortable developing in Java. The reality is, a very large number of people have at least passing familiarity with Visual Basic of some description, either for applications or for scripting and even those who don’t can pick it up fairly quickly.

That’s where B4A comes in. Basic 4 Android is a free and non-free Visual Basic interpreter for the Android operating system, producing native Android code (i.e. it doesn’t require run time interpretation) and if you’re limited in your programming experience or more comfortable with the VB language, it’s very, very usable.

Easy to Understand

Whenever we come to a new language or environment, the simple test we subject it to is “how hard is it to make it say “Hello World“. So let’s compare traditional, Java based Android app development, to B4A for this simple task.

For the sake of brevity, we’ll assume that you already have your SDK, libraries, etc configured, although I will say that either environments in this regard are relatively similar to set up, however B4A assists the users and streamlines this process a bit more than Eclipse does. In any case, it’s a consideration.

I’m drawing my example for the traditional approach from the first Google hit for Android: Hello World, on the day I wrote this article. If you view that link, you’ll see how many steps are required before you even begin writing code.

I’ve posted the code from that site below, to show you the amount of code required for this simple task.

package com.android.test;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class HelloWorld extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button button = (Button) findViewById(R.id.Button01);
        button.setOnClickListener(new OnClickListener() {
           @Override
           public void onClick(View v) {
            Toast.makeText(HelloWorld.this, "Hello World", Toast.LENGTH_SHORT).show();
           }
         });       
    }
}
<?xml version="1.0" encoding="utf-8"?>
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
>
<button android:text="Click Me"
 android:id="@+id/Button01"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"></Button>
</LinearLayout>

Now let’s look at the Hello World article on B4A. Keep in mind this page, while much shorter, covers the installation process, the emulator set up, etc.

Sub Activity_Create(FirstTime As Boolean)
Log("Hello world!")
Msgbox("Hello world?", "First program")
End Sub

That’s it. Job done. No need for XML (B4A makes it for you and even has a very easy to use GUI tool to manage it). Your program is made and you’re collecting the big bucks! (Well, maybe not a lot of people are going to pay to download your Hello World app from Google Play but you get the idea).

Limitations

Obviously, when you’ve got an interpreter turning VB code into native Android code, things might get lost in translation. I’ve personally written a fair few apps in B4A and I haven’t run into any problems, however I can understand how they might occur.

Furthermore, the free version is very limited and to write anything serious, you will need to purchase the full version (less than $100 Aussie dollars)

Otherwise, the bulk of the complaints I read regarding B4A, I’m sorry to say, tend to come from purists and more experienced programmers and generally (not always but often) don’t provide genuine issues with B4A but instead amount to the belief that people using it are “coping out”. I think this, however, misses the point – B4A is precisely for people who don’t have the programming background; giving them a chance to get involved and maybe even make some good apps.

Final Words

While I’m not advocating one development platform over another – they both have their uses, positives and drawbacks, I’d like to draw attention to B4A for the simple reason that I’ve spoken with many people who tried to develop for Android and found it too hard. Had these people tried B4A, they may well have stuck with it and perhaps made some apps that other people in turn could have gotten good use out of.

An interpreter is never going to be as powerful and flexible as a fully skilled programmer, using the native language – however for many people this simply doesn’t matter. B4A is going to offer you everything you need and more. Utilising GPS, Wifi and other phone hardware functionality is ridiculously simple with B4A and this simply cannot be said for native Android development tools. It’s far less daunting and for someone trying to make their first app, I think it may prove to be a better option.

As a final note, this author is in no way affiliated or associated with B4A or any related entities.

Rodney

Rodney's comes from a background of enterprise systems integration and now runs a cloud computing company. He has a love of all things Android and open and loves it when technology makes us amazed or excited. Rodney uses a Samsung Galaxy S3 4G Model and a Samsung Galaxy 10.1.

...or just comment with the form below.
MobileZapCheck 'em Out

Leave a Reply

Start of page