• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.0.1.79
Application User Interface Restrictions

The BlackBerry Dynamics runtime monitors the application user interface in order to enforce a number of enterprise security policies. For example, there may be a policy that the user must always enter their security password when the application makes the transition from background to foreground. There may also be a policy that the user interface must be locked after a period of inactivity.

The application user interface must observe a number of restrictions in order to enable monitoring by the runtime. The application code mustn't depend on having control of the user interface at all times.

Launcher Activity

Every application has a launcher activity. The launcher activity will have the android.intent.category.LAUNCHER category and the android.intent.action.MAIN action in the application's AndroidManifest.xml file. The launcher activity of a BlackBerry Dynamics application must use either indirect or direct authorization initiation, as follows.

  • Call the activityInit method to use indirect authorization initiation.
    • The method should be called from the onCreate method of the launcher activity's class.
  • Call the authorize method to use direct authorization initiation.
    • The method should be called from the onResume method of the launcher activity's class.
    • The application code must ensure that the method is only called once, in case onResume is invoked again later in the application's execution cycle.
    • The launcher activity class must extend one of the BlackBerry Dynamics replacement activity classes, see below.

See the GDAndroid page, under BlackBerry Dynamics Platform Connection, for an introduction to direct and indirect authorization.

Other Activities

Activities other than the launcher must either initiate indirect authorization, or be annotated for BlackBerry Dynamics monitoring, or extend a BlackBerry Dynamics replacement activity class.

Indirect authorization
The activity's class calls activityInit in the same way as the launcher activity, see above. A typical call would be:
GDAndroid.getInstance().activityInit(this);
Monitoring annotation
The activity configuration in the application AndroidManifest.xml file includes a meta-data tag with the name GDMonitorActivity and the value true, as shown in the following snippet:
<meta-data android:name="GDMonitorActivity" android:value="true" />
If monitoring is annotated on any activity then the application would typically have to set its state transition observer explicitly. See under Authorization State Notification Interfaces, above, for details of implicit and explicit observer setting.
Replacement activity extension
The activity class is declared as extending a BlackBerry Dynamics replacement activity class, and isn't a subclass of a native activity class. For each native activity class there is a corresponding replacement class that must be used instead: Each replacement class is a subclass of the corresponding native class. A class that is an extension of a replacement class can override its methods in the normal manner. The base class method must always be called in the overriding method. For example, suppose the application code creates an extension of the com.good.gd.Activity class, and overrides the onUserActivity() method. In that case, the overriding method would have to call the super.onUserActivity() method. Failure to call the base class method from an overriding method could result in abnormal termination of the application.
An activity the extends a replacement activity cannot utilize implicit setting of the GDStateListener observer. See the GDAndroid page, under Authorization State Transition Notification Interfaces for details of implicit and explicit observer setting.

The activities in an application can use a variety of the above methods, but each activity should use only one. For example, there shouldn't be a call to activityInit and a meta-data annotation for the same activity.

Activities that use indirect authorization can extend native or third party activity classes, and aren't restricted to the BlackBerry Dynamics replacement classes. The BlackBerry Dynamics monitoring annotation can be applied even when source code isn't available, for example when the application includes a pre-built JAR library from a third party.

Note that activities other than the designated launcher shouldn't attempt to utilize direct authorization processing.

Some earlier versions of the software development kit for Android required that all activity classes extend a BlackBerry Dynamics replacement activity class, and didn't offer the other two options.

See also
Screen Capture Control
android