See http://developer.android.com/guide/topics/manifest/uses-sdk-element.html
+* The annotation `android_activity` defines a Java class used as an
+ entrypoint to your application. As of now, this annotation should
+ only be used by low level implementations of Nit on Android.
+ It's usefulness will be extended in the future to customize user applications.
+
## Project entry points
Importing `android::landscape` or `android::portrait` locks the generated
# which is a subclass of `Activity` and `Context` (in Java). It represent
# main activity of the running application. Use it to get anything related
# to the `Context` and as anchor to execute Java UI code.
-module native_app_glue is ldflags "-landroid"
+module native_app_glue is
+ ldflags "-landroid"
+ android_activity "android.app.NativeActivity"
+end
import platform
import log
### generate AndroidManifest.xml
dir = android_project_root
- """<?xml version="1.0" encoding="utf-8"?>
+ var manifest_file = new FileWriter.open("{dir}/AndroidManifest.xml")
+ manifest_file.write """
+<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="{{{app_package}}}"
android:versionCode="{{{project.version_code}}}"
android:versionName="{{{app_version}}}">
- <!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk
android:minSdkVersion="{{{app_min_api}}}"
android:targetSdkVersion="{{{app_target_api}}}"
android:debuggable="{{{not release}}}"
{{{icon_declaration}}}
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation">
+"""
- <!-- Our activity is the built-in NativeActivity framework class.
- This will take care of integrating with our NDK code. -->
- <activity android:name="android.app.NativeActivity"
+ for activity in project.activities do
+ manifest_file.write """
+ <activity android:name="{{{activity}}}"
android:label="@string/app_name"
{{{project.manifest_activity_attributes.join("\n")}}}
{{{icon_declaration}}}>
- <!-- Tell NativeActivity the name of our .so -->
- <meta-data android:name=\"android.app.lib_name\"
- android:value=\"main\" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+"""
+ end
+ manifest_file.write """
{{{project.manifest_application_lines.join("\n")}}}
</application>
</manifest>
<!-- END_INCLUDE(manifest) -->
- """.write_to_file("{dir}/AndroidManifest.xml")
+"""
### Link to png sources
# libpng is not available on Android NDK
# Maximum API level on which the application will be allowed to run
var max_api: nullable Int = null
+ # Activities to declare in the manifest
+ var activities = new Array[String]
+
redef fun to_s do return """
name: {{{name or else "null"}}}
namespace: {{{java_package or else "null"}}}
annots = collect_annotations_on_modules("android_manifest_activity", mmodule)
for an in annots do project.manifest_activity_attributes.add an.arg_as_string(self) or else ""
+ annots = collect_annotations_on_modules("android_activity", mmodule)
+ for an in annots do
+ var activity = an.arg_as_string(self)
+ if activity != null then project.activities.add activity
+ end
+
# Get the date and time (down to the minute) as string
var local_time = new Tm.localtime
var local_time_s = local_time.strftime("%y%m%d%H%M")