fplutil
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
Using libfplutil_main

libfplutil_main implements an Android NativeActivity entry point android_main() which calls the traditional C/C++ entry point int main(). This makes it possible to write an application with a int main() entry point (just like any standard C application), link against this library (see Linking) and have it run on Android.

For example, the following prints "Hello World" to the Android log:

#include <android/log.h>
int main(int argc, char *argv[]) {
__android_log_print(ANDROID_LOG_VERBOSE, "test", "Hello World");
return 0;
}

Event Processing

Android applications must process system events otherwise they trigger an "Application Not Responding" dialog (ANR) which prompts the user to close the application. For long running tasks the ProcessAndroidEvents() function makes it easy to process events and avoid the ANR dialog.

For example:

#include <android/log.h>
int main(int argc, char *argv[]) {
int complete = 0;
__android_log_print(ANDROID_LOG_VERBOSE, "test", "Long running task...");
while (!complete) {
// Performing part of a task that takes a long time, set "complete"
// when finished.
// Process events to avoid ANR.
}
__android_log_print(ANDROID_LOG_VERBOSE, "test", "Task complete!");
return 0;
}