Advanced programming / Executing Java code with GMA |
Androidâ„¢ activities can be bundled with your GMA app and called from the Genero code.
A Java-based extension that interacts with the end user must be implemented as an Android Activity, by using the android.app.Android class.
In order to use your Android Activity from the program, it must be integrated in the mobile app Android package (.apk), which is created in the Genero Studio deployment procedure.
package com.myextension; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class MyActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Button button = new Button(this); button.setText("Quit"); setContentView(button); button.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { int resultCode = RESULT_OK; Intent resultData = new Intent(); resultData.putExtra("MyKey", "MyValue"); setResult(resultCode, resultData); finish(); } }); } }
MAIN DEFINE data, extras STRING MENU ON ACTION activity ATTRIBUTES(TEXT="Call bundled activity") CALL ui.Interface.frontCall("android", "startActivityForResult", ["android.intent.action.VIEW", NULL, NULL, NULL, "com.myextension.MyActivity"], [ data, extras ]) MESSAGE "data=",data," / extras=",extras ON ACTION quit EXIT MENU END MENU END MAIN