Android Interface

From Free Pascal wiki
Jump to navigationJump to search

Architecture

As of August 2010 (and Android 2.2), the Android platform can only execute Java Android applications, but these applications can load native libraries. The main idea of the Lazarus Android port is using capability to allow Android to run the existing Lazarus apps. A generic Java application will be created which exposes the Java Android API to the LCL though the Java Native Interface. The Lazarus user application will be built as a Linux-arm library and be attached to the generic Java encapsulating application. Both will then communicate to ensure that the existing LCL applications run under Android with as little changes as possible.

The encapsulating Java program wouldn't need to be changed by Lazarus users, and no knowledge of Java will be necessary to develop Lazarus applications for Android. Of course Java knowledge will be necessary to work on the LCL Android Widgetset.

Roadmap

  1. Learn how to write a Java Android application
  2. Learn how to use the JNI
  3. Start building the encapsulating Java application
  4. Start building the new widgetset
  5. Develop both together until the following components are working: TApplication, TForm, TButton, TComboBox, TEdit, TStaticText

Using the Emulator

Installing the Emulator

Building an emulator image with sdcard support

Step 1: Run the application C:\Program Files\android-sdk-windows\tools\android.bat

Step 2: Create a new image, by clicking the New button as in the image bellow.

Android new image.PNG

Step 3: Set the name and properties of the image, the size of the SDCard and add hardware support for the sdcard, as seen on the image bellow.

Android new image dialog.PNG

Running an emulator image

Step 1: Run the application C:\Program Files\android-sdk-windows\tools\android.bat

Step 2: Select the image

Step 3: Click on the "start" button, as seen bellow.

Android run image.PNG

Copying files to the emulator

You can use a script similar to this one to copy files from your hard-drive to the emulator. Notice that the image must be running and that it must have sdcard support built inside itself.

c:
cd "Program Files"
cd android-sdk-windows
cd tools
adb push C:\Mypath\Somefile.extension /sdcard
pause