oms.home
Class HomeIntents

java.lang.Object
  extended by oms.home.HomeIntents

public class HomeIntents
extends java.lang.Object

OPhone Home Screen is the home screen application in OPhone platform. The class defines some constants used by Home Screen API. If you want to add/change an item on home screen, you can send some Intent to the home screen application. Then the home screen application will process this action.

For example, Fetion is running on background, some message is arriving, Fetion can send an Intent to Home Screen in order to add a symbol on the Fetion's shortcut item.

Here is the sample code to show how to add a symbol on shortcut:

        // Create an Intent for Home Screen Application
        Intent symblIntent = new Intent(HomeIntents.ACTION_SHORTCUT_SYMBOL);
        // If you want to add a symbol to Fetion's shortcut, you should 
        // Get a Fetion's launch intent.  
        Intent mIntent = getFetionLauncherIntent();
        // Set the Intent parameter for symblIntent 
        symblIntent.putExtra(HomeIntents.SHORTCUT_SYMBOL_INTENT, mIntent);
           
        // Create bitmap
        Bitmap bg = BitmapFactory.decodeResource(getResources(),
                R.drawable.shortcut_msgcount);
        Bitmap symbol = Bitmap.createBitmap(bg.getWidth(), bg.getHeight(),
                bg.getConfig());
        Canvas canvas = new Canvas(symbol);
        TextPaint textPaint = new TextPaint();
        canvas.drawBitmap(bg, 0, 0, null);
        canvas.drawText(Integer.toString(mUnreadMessageCount), bg.getWidth() / 2, 14, textPaint);
          
        // Set bitmap data for Intent
        symblIntent.putExtra(HomeIntents.SHORTCUT_SYMBOL_BITMAP, symbol);
        // Set the symbol's position
        symblIntent.putExtra(HomeIntents.SHORTCUT_SYMBOL_POSITION, HomeIntents.SYM_TOP);
           
        // Broadcast intent, then home screen application will process the intent
        sendBroadcast(symblIntent);
        ... ...
 

If Home Screen completes some action, such as adding a shortcut on screen, Home Screen will broadcast a Intent to all BroadcastReceiver.

For example: If you want to do some action after Home Screen finished some work, you should register a broadcast to process Home Screen Applictaion's Intent. Here is the sample code:

1. Create broadcast Receiver

        BroadcastReceiver mHomeIntentReceiver = new BroadcastReceiver() {
            public void onReceive(Context context, Intent intent) {
                final String action = intent.getAction();
                if (HomeIntents.ACTION_LOAD_COMPLETE.equals(action)) {
                // Home Screen loading completes, process code here
                ...
              } else if (HomeIntents.ACTION_ITEM_ADDED.equals(action)) {
                // Adding Item finished, process code here
                ...
                }
            }
        };
 

2. Register receiver on Activity onCreate method

        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            ...
            IntentFilter filter = new IntentFilter();
            filter.addAction(HomeIntents.ACTION_ITEM_ADDED);
            filter.addAction(HomeIntents.ACTION_LOAD_COMPLETE);
            registerReceiver(mHomeIntentReceiver, filter);
            ...
        }
 


Field Summary
static java.lang.String ACTION_CREATE_ITEM
          While an item is added to Home Screen, it will broadcast an Intent with the ACTION_ITEM_ADDED action.
static java.lang.String ACTION_INSTALL_ITEM
          If you want to install a Shortcut Item on Home Screen, you can send the Intent with action ACTION_INSTALL_ITEM to Home Screen.
static java.lang.String ACTION_ITEM_ADDED
          While an item is added to Home Screen, it will broadcast an Intent with the ACTION_ITEM_ADDED action.
static java.lang.String ACTION_LOAD_COMPLETE
          While the Home Screen loading completes, it will broadcast an intent with ACTION_LOAD_COMPLETE action.
static java.lang.String ACTION_SHORTCUT_SYMBOL
          Intent with ACTION_SHORTCUT_SYMBOL action is used to add additional symbol on specified shortcut item.
static java.lang.String EXTRA_ITEM_LAUNCH_INTENT
          If you want to know which item has been added/removed, you should register a broadcast receiver for Home Screen.
static java.lang.String SHORTCUT_SYMBOL_BITMAP
          While adding a symbol on shortcut item, you should set the bitmap data for Intent.
static java.lang.String SHORTCUT_SYMBOL_INTENT
          If you want to add a symbol on a shortcut, you should set this parameter.
static java.lang.String SHORTCUT_SYMBOL_POSITION
          If you want to add a symbol on application's shortcut, you need set the symbol's position.
static int SYM_BOTTOM
          Bottom Position.
static int SYM_BOTTOM_LEFT
          Bottom Left Position.
static int SYM_BOTTOM_RIGHT
          Bottom Right Position.
static int SYM_CENTER
          Center Position.
static int SYM_LEFT
          Left Position.
static int SYM_RIGHT
          Right Position.
static int SYM_TOP
          Top Position.
static int SYM_TOP_LEFT
          Top Left Position.
static int SYM_TOP_RIGHT
          Top Right Position.
 
Constructor Summary
HomeIntents()
           
 
Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_LOAD_COMPLETE

public static final java.lang.String ACTION_LOAD_COMPLETE
While the Home Screen loading completes, it will broadcast an intent with ACTION_LOAD_COMPLETE action.

See Also:
Constant Field Values

ACTION_CREATE_ITEM

public static final java.lang.String ACTION_CREATE_ITEM
While an item is added to Home Screen, it will broadcast an Intent with the ACTION_ITEM_ADDED action.

See Also:
Constant Field Values

ACTION_INSTALL_ITEM

public static final java.lang.String ACTION_INSTALL_ITEM
If you want to install a Shortcut Item on Home Screen, you can send the Intent with action ACTION_INSTALL_ITEM to Home Screen. Notice: And if you want to remove a Shortcut from Home Screen, you can long press the Shortcut icon and select 'delete' icon directly.

See Also:
Constant Field Values

ACTION_ITEM_ADDED

public static final java.lang.String ACTION_ITEM_ADDED
While an item is added to Home Screen, it will broadcast an Intent with the ACTION_ITEM_ADDED action.

See Also:
Constant Field Values

ACTION_SHORTCUT_SYMBOL

public static final java.lang.String ACTION_SHORTCUT_SYMBOL
Intent with ACTION_SHORTCUT_SYMBOL action is used to add additional symbol on specified shortcut item. For example, if some application's status has been changed, you can add a symbol on the specified Shortcut using the Intent with ACTION_SHORTCUT_SYMBOL action.

See Also:
Constant Field Values

SHORTCUT_SYMBOL_POSITION

public static final java.lang.String SHORTCUT_SYMBOL_POSITION
If you want to add a symbol on application's shortcut, you need set the symbol's position. Key 'SHORTCUT_SYMBOL_POSITION' is the position parameter constant. For the values, @see SYM_CENTER, SYM_TOP

See Also:
Constant Field Values

SYM_CENTER

public static final int SYM_CENTER
Center Position.

See Also:
Constant Field Values

SYM_TOP

public static final int SYM_TOP
Top Position.

See Also:
Constant Field Values

SYM_RIGHT

public static final int SYM_RIGHT
Right Position.

See Also:
Constant Field Values

SYM_BOTTOM

public static final int SYM_BOTTOM
Bottom Position.

See Also:
Constant Field Values

SYM_LEFT

public static final int SYM_LEFT
Left Position.

See Also:
Constant Field Values

SYM_TOP_LEFT

public static final int SYM_TOP_LEFT
Top Left Position.

See Also:
Constant Field Values

SYM_TOP_RIGHT

public static final int SYM_TOP_RIGHT
Top Right Position.

See Also:
Constant Field Values

SYM_BOTTOM_RIGHT

public static final int SYM_BOTTOM_RIGHT
Bottom Right Position.

See Also:
Constant Field Values

SYM_BOTTOM_LEFT

public static final int SYM_BOTTOM_LEFT
Bottom Left Position.

See Also:
Constant Field Values

SHORTCUT_SYMBOL_BITMAP

public static final java.lang.String SHORTCUT_SYMBOL_BITMAP
While adding a symbol on shortcut item, you should set the bitmap data for Intent. SHORTCUT_SYMBOL_BITMAP is the key for bitmap data parameter.

See Also:
Constant Field Values

SHORTCUT_SYMBOL_INTENT

public static final java.lang.String SHORTCUT_SYMBOL_INTENT
If you want to add a symbol on a shortcut, you should set this parameter. Such as: Intent intentToHomeScreen = new Intent(HomeIntents.ACTION_SHORTCUT_SYMBOL); intentToHomeScreen.putExtra(HomeIntents.SHORTCUT_SYMBOL_INTENT, launchIntentOfShortcut);

See Also:
Constant Field Values

EXTRA_ITEM_LAUNCH_INTENT

public static final java.lang.String EXTRA_ITEM_LAUNCH_INTENT
If you want to know which item has been added/removed, you should register a broadcast receiver for Home Screen. Then set this parameter. Such as: Intent intent = broacastIntent.getParcelableExtra(HomeIntents.EXTRA_ITEM_LAUNCH_INTENT); From this way, You can get the launch intent of the shortcut.

See Also:
Constant Field Values
Constructor Detail

HomeIntents

public HomeIntents()