Mobile RMTCMD support

This post is short introduction to a new feature - STRRMTCMD for Android. In latest mobile application update we added support to start another Android application from STRRMTCMD.

If you are IBM I user, then you probably know about STRRMTCMD host command to start desktop application (through our HLL integration) or to use it to open URL link etc.

Now we introduced 2 new command attributes:

  • var: to record temp key/value list
  • android: to start Android application
Store key/value pairs

Key value pairs are optional parameters that will be send to starting Android application. They are set in URL parameter format.

For example, calling following command from terminal:

STRPCCMD PCCMD('var:a=1&b=2')

will create JavaScript Object {a:1, b:2}.

If STRPCCMD is too short to pass all parameters, just call it again with new set of values. Values will be added to exiting JavaScript Object without deleting previous values.

NOTE: If you repeat exiting key, previous will be overwritten.

To clear JavaScript Object, just call empty var: attribute.

STRPCCMD PCCMD('var:')

Starting Android app

Every Android app has unique namespace (package name) under which it is built. To start another Android app, execute following command with application namespace:

STRPCCMD PCCMD('android:com.android.settings')

In this example Android system settings will start.

Of course we can create our own mobile application and use it from IBM I.

Android application is invoked through Intents which can contain additional parameteres. In this case, all key/value pairs stored before calling Android app will be passed to an application as an extras values.

Here is a simple example what our Android Terminal Application will do based on previous examples:


final PackageManager pm = context.getPackageManager();

// Create start Intent for given appliaction namespace
final Intent launchIntent = pm.getLaunchIntentForPackage("com.android.settings");

// If requested application exists on mobile device, 
// fill key/value pairs and start application
if (launchIntent != null) {
  launchIntent.putExtra("a", "5");
  launchIntent.putExtra("b", "2");
  launchIntent.putExtra("c", "2");
  context.startActivity(launchIntent);
}
Startup Types

Application can be called as a plugin as described in developer manual or as a standard application.

If called as a plugin, secondary application will be called using startActivityForResult otherwise startActivity will be used.

To start application as a plugin, set #RC=nn through STRRMTCMD as var:#RC=nn where nn is one of request codes as described in develoepr manual.

NOTE: Request code can be IO_GREENSCREENS_MACRO or IO_GREENSCREENS_CODE

To pass current screen data, set #SCR=1 through STRRMTCMD as var:#SCR=1

To get screen data in 3rd party application use constant key as described in developer manual:

intent.getString(IO_GREENSCREENS_SCREEN_DATA);

Called intent will contain current service url address as described in developer manual:

intent.getString(IO_GREENSCREENS_SERVICE);

If request code was IO_GREENSCREENS_CODE, values returned from 3rd party application can be pasted into active session or can trigger actions as described in developer manual.

Use File class for spool directory to find last spool file for extra processing.

File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "GreenScreens");
Advanced usage

Advanced usage is about generating custom dynamic data from live terminal as extracting screen data, last cursor position or last received spool file. All those data can be generated dynamically and sent to 3rd party Android application. More about advanced usage please look here.

Conclusion

This is just a short introduction how to enable legacy 5250 application to start Android application and pass some values from IBM I system. If one is using custom developed Android apps with special usage, the whole new possibilities opens.

For example, one can use custom app to integrate invoice processing with PayPal or any other Internet service which support API and integrations.

We hope this gives you enough information to tickle your imagination.