Oracle Fusion Middleware Java API Reference for Oracle Mobile Application Framework
2.0.0.0.0

E36392-01

oracle.adfmf.framework.api
Class AdfmfContainerUtilities

Object
  extended by oracle.adf.model.datacontrols.device.BaseProxy
      extended by oracle.adfmf.framework.api.AdfmfContainerUtilities

public class AdfmfContainerUtilities
extends oracle.adf.model.datacontrols.device.BaseProxy


Constructor Summary
AdfmfContainerUtilities()
           
 
Method Summary
static int getApplicationIconBadgeNumber()
          Get current badge value of on application icon
static oracle.adfmf.framework.ApplicationInformation getApplicationInformation()
          Gets ApplicationInformation object containing the information about the application.
static FeatureInformation getFeatureById(String featureId)
          Returns the feature information for the passed in feature id.
static FeatureInformation getFeatureByName(String featureName)
          Returns the feature information for the passed in feature name.
static FeatureInformation[] getFeatures()
          Gets an array of FeatureInformation objects that provide information about the features that are available in this session of the MAF application and should be displayed on a custom springboard.
static void gotoDefaultFeature()
          Activates the default feature.
static void gotoFeature(String featureId)
          Activates the feature with the given id.
static void gotoSpringboard()
          Activates the springboard.
static void hideNavigationBar()
          Hides navigation bar.
static void hideSpringboard()
          Hides springboard.
static Object invokeContainerJavaScriptFunction(String featureId, String methodName, Object[] args)
          Invokes a Javascript method with the given arguments on the specified feature.
static Object invokeContainerMethod(String className, String methodName, Object[] args)
          Invokes a native method on the specified class with the given arguments.
static void resetApplication(String message)
          Reset the application Calling this method will cause the application to be reset.
static void resetFeature(String featureId)
          Resets the feature with the given id.
static void resetFeature(String featureId, boolean gotoTheFeature)
          Resets the feature with the given id and optionally navigates to that feature.
static void sendEmail(java.util.HashMap options)
          Display the device's e-mail interface, and optionally pre-populate certain fields.
static void sendSMS(java.util.HashMap options)
          Display the device's text messaging (SMS) interface, and optionally pre-populate certain fields.
static void setApplicationIconBadgeNumber(int badge)
          Set a badge on application icon
static void showNavigationBar()
          Shows navigation bar.
static void showSpringboard()
          Shows springboard.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdfmfContainerUtilities

public AdfmfContainerUtilities()
Method Detail

getApplicationIconBadgeNumber

public static int getApplicationIconBadgeNumber()
Get current badge value of on application icon

Returns:
the current badge value, 0 if no badge

getApplicationInformation

public static oracle.adfmf.framework.ApplicationInformation getApplicationInformation()
                                                                               throws AdfException
Gets ApplicationInformation object containing the information about the application. This can be used to get the application name for a custom springboard. Additional information such as vendor, version and application id are provided as well.

Example :

 import oracle.adfmf.framework.api.AdfmfContainerUtilties;
 ...
   try
   {
     ApplicationInformation ai = AdfmfContainerUtilities.getApplicationInformation();
     ...
   }
   catch(AdfException e)
   {
     // handle the exception
   }
 

Returns:
A ApplicationInformation object containing application level metadata. This includes application name, vendor, version and application id.
Throws:
AdfException

getFeatureById

public static FeatureInformation getFeatureById(String featureId)
                                         throws AdfException
Returns the feature information for the passed in feature id.

Example :

 import oracle.adfmf.framework.api.AdfmfContainerUtilties;
 ...
   try
   {
     FeatureInformation fi = AdfmfContainerUtilities.getFeatureById("feature.id");
   }
   catch(AdfException e)
   {
     // handle the exception
   }
 

Parameters:
featureId - The id of the feature to retrieve
Throws:
AdfException - If featureId is null, blank, invalid or the logged in user is not authorized for the feature.

getFeatureByName

public static FeatureInformation getFeatureByName(String featureName)
                                           throws AdfException
Returns the feature information for the passed in feature name.

Example :

 import oracle.adfmf.framework.api.AdfmfContainerUtilties;
 ...
   try
   {
     FeatureInformation fi = AdfmfContainerUtilities.getFeatureByName("feature.name");
   }
   catch(AdfException e)
   {
     // handle the exception
   }
 

Parameters:
featureName - Name of the feature to retrieve
Throws:
AdfException

getFeatures

public static FeatureInformation[] getFeatures()
                                        throws AdfException
Gets an array of FeatureInformation objects that provide information about the features that are available in this session of the MAF application and should be displayed on a custom springboard. These features have already been filtered by the evaluation of constraints. These are the features that would normally be displayed on the default springboard.

Example :

 import oracle.adfmf.framework.api.AdfmfContainerUtilties;
 ...
   try
   {
     FeatureInformation[] fia = null;
     fia = AdfmfContainerUtilities.getFeatures();

     for(int f = 0; f < fia.length; ++f)
     {
       FeatureInformation fi = fia[i];
       ...
     }
   }
   catch(AdfException e)
   {
     // handle the exception
   }
 

Returns:
An array of FeatureInformation objects each representing a feature that is available. This will include the feature id, the feature name, a path to the feature icon and a path to the feature image. Normally a springboard will display the name of the feature and the image for that feature.
Throws:
AdfException

gotoDefaultFeature

public static void gotoDefaultFeature()
Activates the default feature.

Example :

 import oracle.adfmf.framework.api.AdfmfContainerUtilties;
 ...
   try
   {
     AdfmfContainerUtilities.gotoDefaultFeature();
   }
   catch(AdfException e)
   {
     // handle the exception
   }
 


gotoFeature

public static void gotoFeature(String featureId)
                        throws AdfException
Activates the feature with the given id.

Example :

 import oracle.adfmf.framework.api.AdfmfContainerUtilties;
 ...
   try
   {
     AdfmfContainerUtilities.gotoFeature("feature.id");
   }
   catch(AdfException e)
   {
     // handle the exception
   }
 

Parameters:
featureId - The id of the feature to activate
Throws:
AdfException - If featureId is null, blank, invalid or the logged in user is not authorized for the feature.

gotoSpringboard

public static void gotoSpringboard()
Activates the springboard.

Example :

 import oracle.adfmf.framework.api.AdfmfContainerUtilties;
 ...
   try
   {
     AdfmfContainerUtilities.gotoSpringboard();
   }
   catch(AdfException e)
   {
     // handle the exception
   }
 


hideNavigationBar

public static void hideNavigationBar()
Hides navigation bar.

Example :

 import oracle.adfmf.framework.api.AdfmfContainerUtilties;
 ...
   try
   {
     AdfmfContainerUtilities.hideNavigationBar();
   }
   catch(Exception e)
   {
     // handle the exception
   }
 


hideSpringboard

public static void hideSpringboard()
Hides springboard.

Example :

 import oracle.adfmf.framework.api.AdfmfContainerUtilties;
 ...
   try
   {
     AdfmfContainerUtilities.hideSpringboard();
   }
   catch(Exception e)
   {
     // handle the exception
   }
 


invokeContainerJavaScriptFunction

public static Object invokeContainerJavaScriptFunction(String featureId,
                                                       String methodName,
                                                       Object[] args)
                                                throws AdfException
Invokes a Javascript method with the given arguments on the specified feature. Returns the result of the method execution.

Parameters:
featureId - The id of the feature on which to invoke the method
methodName - method name
args - array of arguments to be passed to method
Returns:
a JSON object
Throws:
AdfException -

To illustrate how this can be used, we did the following:
  • included a simple appFunction.js file to feature1 (by adding it to feature1 content's include in JDeveloper).
  • added a command button with the actionListener="#{managedBean1.invokeApplicationJavaScriptFuntions}"

appFunctions.js
    (function()
    {
       if (!window.application) window.application = {};

       application.testFunction = function()
       {
          var args = arguments;

          alert("APP ALERT " + args.length + " ");
          return "application.testFunction - passed";
       };
    })();
 

invokeApplicationJavaScriptFuntions
    public void invokeApplicationJavaScriptFuntions(ActionEvent actionEvent) {
        AdfmfContainerUtilities.invokeContainerJavaScriptFunction("feature1", "application.testFunction", new Object[] {} );
        AdfmfContainerUtilities.invokeContainerJavaScriptFunction("feature1", "application.testFunction", new Object[] {"P1"} );
        AdfmfContainerUtilities.invokeContainerJavaScriptFunction("feature1", "application.testFunction", new Object[] {"P1", "P2"} );
    }
 

Now when the user presses the button they will see three alerts:
        APP ALERT 0
        APP ALERT 1
        APP ALERT 2
 

invokeContainerMethod

public static Object invokeContainerMethod(String className,
                                           String methodName,
                                           Object[] args)
Invokes a native method on the specified class with the given arguments. Returns the result of method execution.

Parameters:
className - class name: Always specify fully qualified class name for both iOS and Android.
Example: If className "MyPackage.MySubpackage.MyClass" is set, class MyClass is invoked on iOS, while class MyPackage.MySubpackage.MyClass is invoked on Android.
methodName - method name
args - array of arguments to be passed to method
Returns:
Object

resetFeature

public static void resetFeature(String featureId)
                         throws AdfException
Resets the feature with the given id.

Example :

 import oracle.adfmf.framework.api.AdfmfContainerUtilties;
 ...
   try
   {
     AdfmfContainerUtilities.resetFeature("feature.id");
   }
   catch(AdfException e)
   {
     // handle the exception
   }
 

Parameters:
featureId - The id of the feature to reset
Throws:
AdfException - If featureId is null, blank, invalid or the logged in user is not authorized for the feature.

resetFeature

public static void resetFeature(String featureId,
                                boolean gotoTheFeature)
                         throws AdfException
Resets the feature with the given id and optionally navigates to that feature.

Example

 import oracle.adfmf.framework.api.AdfmfContainerUtilties;
 ...
   try {
     AdfmfContainerUtilities.resetFeature("feature.id", false);
   }catch(AdfException e) {
     // handle the exception
   }
 

Parameters:
featureId - The id of the feature to reset
gotoTheFeature - Whether or not to navigate to the feature
Throws:
AdfException - If featureId is null, blank, invalid or the logged in user is not authorized for the feature.

sendEmail

public static void sendEmail(java.util.HashMap options)
Display the device's e-mail interface, and optionally pre-populate certain fields.

After this interface is displayed, user can choose to either send the e-mail or discard it. Note that it is not possible to automatically send the e-mail due to device/carrier restrictions; only the end user can actually send the e-mail. The device must also have at least one e-mail account configured to send e-mail; otherwise, an error will be displayed indicating that no e-mail accounts could be found.

Examples :
Populate an e-mail to 'john.doe@foo.com', copy 'jane.doe@bar.com', with the subject 'Test message', and the body 'This is a test message'

 HashMap options = new HashMap();

 options.put("to", "john.doe@foo.com");
 options.put("cc", "jane.doe@bar.com");
 options.put("subject", "Test message");
 options.put("body", "This is a test message");

 AdfmfContainerUtilities.sendEmail(options);
 
Taking the same example, but now adding a BCC to 'mary.may@another.com' and 'lary.day@another.com' and attaching two files.
NOTE: By not specifying a value for the mimeTypes parameter, you are telling the framework to automatically determine the MIME type for each of the attachments.
 HashMap options = new HashMap();

 options.put("to", "john.doe@foo.com");
 options.put("cc", "jane.doe@bar.com");
 options.put("bcc", "mary.may@another.com,lary.day@another.com");
 options.put("subject", "Test message");
 options.put("body", "This is a test message");
 options.put("attachments", "path/to/file1.txt,path/to/file2.png");
 AdfmfContainerUtilities.sendEmail(options);
 

Parameters:
options - is a HashMap object with the following optional properties:
  • to: recipients (comma-separated)
  • cc: CC recipients (comma-separated)
  • subject: message subject
  • body: message body
  • bcc: BCC recipients (comma-separated)
  • attachments: list of filenames to attach to the e-mail (comma-separated)
  • mimeTypes:
    • iOS: List of MIME types to use for the attachments (comma-separated). Specify null to let the framework automatically determine the MIME types. It is also possible to only specify the MIME types for selected attachments; see examples below.
    • Android: MIME type in Android isn't true MIME type but just a way for Android to filter applications to be shown in the application chooser dialog. But empty MIME type doesn't work and throws exception. So if no MIME type is passed in, we use "plain/text" by default. Also, if there are multiple attachment types, user doesn't need to provide multiple MIME types, but can provide just most suitable MIME type (as per Android documentation). That being said, if the user has an application which is being deployed to both iOS and Android, they can pass in the comma-separated list of mime types and Android will still work fine.
Throws:
AdfException

sendSMS

public static void sendSMS(java.util.HashMap options)
Display the device's text messaging (SMS) interface, and optionally pre-populate certain fields. After this interface is displayed, user can choose to either send the SMS or discard it. Note that it is not possible to automatically send the SMS due to device/carrier restrictions; only the end user can actually send the SMS.

Example:

Populate an SMS message to '1234567890' with the body 'This is a test message'

 HashMap options = new HashMap();

 options.put("to", "1234567890");
 options.put("body", "This is a test message");
 AdfmfContainerUtilities.sendSMS(options);
 

Parameters:
options - is a HashMap object with the following optional properties:
  • to: recipients (comma-separated)
  • body: message body
Throws:
AdfException

setApplicationIconBadgeNumber

public static void setApplicationIconBadgeNumber(int badge)
Set a badge on application icon

Parameters:
badge - the badge value

showNavigationBar

public static void showNavigationBar()
Shows navigation bar.

Example :

 import oracle.adfmf.framework.api.AdfmfContainerUtilties;
 ...
   try
   {
     AdfmfContainerUtilities.showNavigationBar();
   }
   catch(Exception e)
   {
     // handle the exception
   }
 


showSpringboard

public static void showSpringboard()
Shows springboard.

Example :

 import oracle.adfmf.framework.api.AdfmfContainerUtilties;
 ...
   try
   {
     AdfmfContainerUtilities.showSpringboard();
   }
   catch(Exception e)
   {
     // handle the exception
   }
 


resetApplication

public static void resetApplication(String message)
Reset the application Calling this method will cause the application to be reset. The application will be stopped as though the program were being gracefully terminated by the user. The caller should make no assumption that the application will be immediately restarted as that is a platform dependent operation. Instead the caller should assume only that the application will be stopped and nothing will be run until the application is restarted sometime later, which may not actually occur. The supplied message is used to inform the user as to why the application is being restarted. It is recommended to provide an appropriate message. The supplied message will displayed alongside a system provided message to alert the application user. If no message is supplied only the system provided message will be displayed. Restarting an application should be used only when resetting individual features is not sufficient.
 import oracle.adfmf.framework.api.AdfmfContainerUtilties;
 ...
   try
   {
     AdfmfContainerUtilities.restartApplication("New content is available.");
   }
   catch(Exception e)
   {
     // handle the exception
   }
 

Parameters:
message - a message describing the reason the application is being restarted, or null if no message is required

Oracle Fusion Middleware Java API Reference for Oracle Mobile Application Framework
2.0.0.0.0

E36392-01

Copyright © 2014 Oracle. All Rights Reserved.