Tutorials & Examples

Android development starts here. Please do not post questions in this sub-forum.

[B4X] Documentation Booklets

The B4X documentation booklets are available in PDF format, Download Link.
All files are included in the zip file in the link above, pdf booklets and all the source code.

You can also...
 
Last edited:

[B4X] "Code Smells" - common mistakes and other tips

"Code smells" are common patterns that can indicate that there is a problem in the code. A problem doesn't mean that the code doesn't work, it might be that it will be difficult to maintain it or...
 
Last edited:

[B4X] Features that Erel recommends to avoid

Many things have changed in B4X and also in the underlying platforms. I will try to list here all kinds of (old) features that have better alternatives.
B4X is backward compatible so these...
 
Last edited:

Installing Basic4android and Android SDK

Last edited:

Hello world - Installing Android Emulator

Guess my number - Visual designer & Events

Connecting your device to the IDE

Introduction

A program called adb.exe - Android Debug Bridge - is the key component that is used to communicate between programs on your desktop and the emulator or device. adb can be...
 
Last edited:

Android Process and activities life cycle

New video tutorial:



Lets start simple:
Each B4A program runs in its own process.
A process has one main thread which is also named the UI thread which lives as long as the...
 
Last edited:

Logcat viewing

The Basic4Android IDE contains a mysterious tab entitled "Logcat" in the right hand pane.

This archive contains a help file that will tell you what a Logcat is and also contains a more...
 

Attachments

  • B4ALogViewer1.2.zip
    16.3 KB · Views: 877

Currency Converter - Http web services and more

Attachments

  • CurrencyConverter.zip
    9.8 KB · Views: 2,972

http Form POST

HI,
due i've needed it...here you are:
B4X:
      Dim url As String
      Dim myHttpRequest As HttpRequest
      url = "https://yourURLhere.html"
      Dim str() As Byte
      Dim form As...
 

ListView tutorial

Don't use ListView.
Use xCustomListView - it is more powerful, easier to work with and cross platform.
 
Last edited:

Getting help for Object and methods

The IDE Intellisense is wonderful for actually writing code but for browsing the available objects to see what is on offer it is a bit tedious so this afternoon I have knocked up this pretty awful...
 

Attachments

  • B4AHelp1.7.zip
    55.6 KB · Views: 447
Last edited:

StateListDrawable example

StateListDrawable is a drawable objects that holds other drawables. Based on the view's current state a child drawable is selected.
StateListDrawable holds a list of states. States can be...
 

MediaPlayer tutorial

Attachments

  • MediaPlayer.zip
    9.5 KB · Views: 6,804

GPS tutorial

This example shows how to work with the GPS library.

upload_2016-6-23_9-56-49.png


The GPS object is declared in the Starter service. It is easier to put the GPS in a service and not in an Activity as the...
 

Attachments

  • GPS.zip
    8.1 KB · Views: 6,799
Last edited:

Two activities example

An improved version, based on CallSubDelayed is available here.
This example demonstrates how to work with more than one activity and how to pass information between the activities.
In...
 

Attachments

  • TwoActivities.zip
    6.7 KB · Views: 5,943

ScrollView example

The ScrollView is a very useful container which allows you to show many other views on a small screen.
The ScrollView holds an inner panel view which actually contains the other views.
The user...
 

Flickr Viewer

Attachments

  • FlickrViewer.zip
    7.2 KB · Views: 1,749

Orientation and accelerometer

The attached program displays the values of the different sensors:

sensors.png


It creates a PhoneSensors object for each type of sensor.
As you can...
 

Attachments

  • SensorsExample.zip
    7.5 KB · Views: 1,607
Last edited:

Open the browser with a specific web page

Opening the browser is very simple.
First you need to add a reference to the Phone library.
Then:
B4X:
    Dim p As PhoneIntents
    StartActivity(p.OpenBrowser("http://www.b4x.com"))
...
 

Text files

Many applications require access to a persistent storage. The two most common storage types are files and databases.
We will cover text files in this tutorial.

The predefined Files object has...
 

TabHost tutorial

Last edited:
Top