The Application module provides abstraction over the platform-specific Application implementations. It is the main BCL module and is required for other BCL modules to work properly. The default bootstrap.js implementation for each platform loads and initializes this module.
var app = require("application");
The pre-required app
module is used throughout the following code snippets.
// The native app instance depends on the target platform
var nativeAppInstance;
app.init(nativeAppInstance);
Use the following code in case you need to check somewhere in your code the platform you are running against:
if (app.android) {
// we are running on Android device
} else if (app.ios) {
// we are running on iOS device
}
Accessing the Android-specific object instance (will be undefined if running on iOS)
var androidApp = app.android;
Using the Android Application context
var context = app.android.context;
// get the Files (Documents) folder (directory)
var dir = context.getFilesDir();
Tracking the current Activity
if (androidApp.currentActivity === androidApp.startActivity) {
// We are currently in the main (start) activity of the application
}