|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.app.Listener
danger.app.Application
public class Application
Application interface to the Application class This class is extended by all applications.
| Field Summary | |
|---|---|
static int |
QUIT_REASON_DISCARD
Specifies that the app is being discarded and datastores removed. |
static int |
QUIT_REASON_LOW_BATTERY
Specifies that the app is being quit because of low battery. |
static int |
QUIT_REASON_POWER_OFF
Specifies that the app is being quit because the user is powering off the device. |
static int |
QUIT_REASON_REBOOT
Specifies that the app is being quit because the device is about to reboot. |
static int |
QUIT_REASON_REMOVED
Specifies that the app is being removed and stored in the vault. |
static int |
QUIT_REASON_UNKNOWN
Specifies that the app is being quit but the reason is not known. |
| Constructor Summary | |
|---|---|
Application()
Constructs a new Application object. |
|
| Method Summary | |
|---|---|
protected void |
addQuickAccessItem(Bitmap bitmap,
CharSequence text,
Object data)
Add a pending item to the QuickAccess window list. |
protected void |
addQuickAccessItem(Bitmap bitmap,
CharSequence text,
String uniqueID,
Object data)
Add a unique pending item to the QuickAccess window list. |
boolean |
allowEntryInSystemLock()
Override to allow this app to be active in system lock. |
void |
bringToForeground()
Bring yourself to the foreground. |
void |
emptyTrash(String subTrash)
Override this method to empty the sub-trash with the specified description. |
Event |
event()
Return an event initialized with the given parameters. |
Event |
event(Event orig)
Return an event initialized with the given parameters. |
Event |
event(int type)
Return an event initialized with the given parameters. |
Event |
event(int type,
int what)
Return an event initialized with the given parameters. |
Event |
event(int type,
int what,
int data)
Return an event initialized with the given parameters. |
Event |
event(int type,
int what,
int data,
Object argument)
Return an event initialized with the given parameters. |
Event |
event(Listener target,
int type)
Return an event initialized with the given parameters. |
Event |
event(Listener target,
int type,
int what)
Return an event initialized with the given parameters. |
Event |
event(Listener target,
int type,
int what,
int data)
Return an event initialized with the given parameters. |
Event |
event(Listener target,
int type,
int what,
int data,
int modifiers)
Return an event initialized with the given parameters. |
Event |
event(Listener target,
int type,
int what,
int data,
int modifiers,
int timestamp,
Object argument)
Return an event initialized with the given parameters. |
Event |
event(Listener target,
int type,
int what,
int data,
Object argument)
Return an event initialized with the given parameters. |
AlertWindow |
getAlert(int id,
Listener listener)
Get the alert (but don't show it yet) with the specified resource id. |
Bitmap |
getBitmap(int id)
Get a bitmap from the resource database. |
Bundle |
getBundle()
Get the application information. |
CharSequence |
getChooserFolderLabel()
Access the label that appears next to the application's icon in a chooser folder splash screen. |
static Application |
getCurrentApp()
Get the current application. |
DialogWindow |
getDialog(int id,
Listener listener)
Get the dialog (but don't show it yet) with the specified resource id. |
ScreenWindow |
getFrontScreenWindow()
Get the frontmost, visible screen window that belongs to this application. |
Window |
getFrontWindow()
Get the frontmost, visible window that belongs to this application. |
String |
getLocaleString(String locale,
int id)
Get a localized string resource from the resource database. |
Listener |
getNetworkListener()
Get the current listener for network events. |
Resource |
getResource(int type,
int id)
Get a resource from the resource database. |
ResourceDatabase |
getResources()
Get the resource database associated with this application. |
String |
getString(int id)
Get a string resource from the resource database. |
String[] |
getStringArray(int id)
Get a string array resource from the resource database. |
TextInputAlertWindow |
getTextInputAlert(int id,
Listener listener)
Get the text input alert (but don't show it yet) with the specified resource id. |
boolean |
handleLauncherMenuShortcut(char inChar)
Handle a menu shortcut from the launcher application This method is called when the user types a menu shortcut in the launcher application. |
void |
hideActiveMenu()
Hide the currently active menu, if one is visible. |
void |
launch()
The application was launched. |
static void |
launchApp(Bundle ai)
Launch the specified application. |
void |
networkEvent(Object obj)
Receive a network event from the system. |
protected void |
onQuickAccessItemSelected(Object argument)
Respond to a pending item for this application being selected. |
void |
openURL(URL url)
Receive and handle a URL based request. |
void |
openURLInBackground(URL url)
Receive and handle a URL based request. |
void |
quit()
Quit the application. |
void |
quit(int reason)
Quit the application. |
boolean |
receiveEvent(Event e)
Receive a new event. |
void |
receiveMessage(int inMessage,
int inData,
Object inArgument)
Deprecated. Unused. |
static boolean |
registerForEvent(Listener inListener,
int event)
Register to receive events of a certain type. |
static boolean |
registerForLeftShoulderHeld(String recipient,
IPCMessage msg,
int priority)
Register to handle the case of the left shoulder button being held in the Jump screen. |
void |
removeAllQuickAccessItems()
Remove all pending items for this application that are currently visible in the QuickAccess window. |
void |
removeQuickAccessItem(Object data)
Remove a pending item for this application that is currently visible in the QuickAccess window. |
void |
removeQuickAccessItem(String uniqueID)
Remove a pending item for this application that is currently visible in the QuickAccess window. |
void |
removeQuickAccessItem(String uniqueID,
Object data)
Remove a unique pending item for this application that is currently visible in the QuickAccess window. |
void |
renderSplashScreen(View inView,
Pen inPen)
Display the application's splash screen. |
void |
resume()
Resume the application. |
void |
returnToLauncher()
Return to the Chooser. |
static void |
setAppImpl(danger.app.AppImpl ai)
Set the application implementation for the system. |
void |
setChooserFolderLabel(CharSequence label)
Change the label that appears next to the application's icon in a chooser folder splash screen. |
void |
setLargeIcon(Bitmap inIcon)
Set the large icon for this application. |
void |
setMiniIcon(Bitmap inIcon)
Set the mini icon for this application. |
protected void |
setName(String appName)
Change the name of an application. |
protected void |
setNetworkListener(Listener networkListener)
Set the current listener for network events. |
protected void |
setReceiveConnectivityEvents(boolean receiveConnectivityEvents)
Register this application as being interested in network connectivity events. |
protected void |
setShowInChooserMenu(boolean showInChooserMenu)
Deprecated. For internal use only. |
void |
setSmallIcon(Bitmap inIcon)
Set the small icon for this application. |
void |
setSplashScreenSize(int width,
int height)
Specify that size of the splash screen. |
AlertWindow |
showAlert(int id)
Show the alert with the specified resource id. |
AlertWindow |
showAlert(int id,
Listener listener)
Show the alert with the specified resource id. |
DialogWindow |
showDialog(int id,
Listener listener)
Show the dialog with the specified resource id. |
TextInputAlertWindow |
showTextInputAlert(int id,
Listener listener)
Show the text input alert with the specified resource id. |
void |
suspend()
Suspend the application. |
protected void |
unload()
Should be the last thing called as a response to quit() - this will abort() the app's dispatcher and finalize unloading |
static boolean |
unregisterForEvent(Listener inListener,
int event)
Unregister for events of a certain type, as registered using registerForEvent(danger.app.Listener, int). |
static void |
unregisterForLeftShoulderHeld(String recipient)
Unregister the specified recipient as the handler of the left shoulder button being held in the Jump screen. |
void |
updateIcons()
Notify the system that the application's icons have changed. |
void |
updatePreviewScreen()
Request that the system redisplay the application's splash screen. |
boolean |
wantsShiftKeyEnabledOutsideTextFields()
Specify whether this application wants to enable use of the shift key outside text edit fields. |
| Methods inherited from class danger.app.Listener |
|---|
cancelEvents, childEventPump, childEventPumpDone, eventProblem, isDispatchingThread, receiveEventInternal, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendLowPriorityEvent |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int QUIT_REASON_REBOOT
quit(int).
public static final int QUIT_REASON_POWER_OFF
quit(int).
public static final int QUIT_REASON_DISCARD
quit(int).
public static final int QUIT_REASON_REMOVED
quit(int).
public static final int QUIT_REASON_LOW_BATTERY
quit(int).
public static final int QUIT_REASON_UNKNOWN
quit(int).
| Constructor Detail |
|---|
public Application()
| Method Detail |
|---|
public boolean receiveEvent(Event e)
super.receiveEvent(Event) to enable default processing on the event.
Returning false is insufficient.
receiveEvent in class Listenere - An Event object containing the event type and data.
true if the method handled the event.public void launch()
public boolean allowEntryInSystemLock()
public boolean handleLauncherMenuShortcut(char inChar)
inChar - The character held down with the menu key.
public void receiveMessage(int inMessage,
int inData,
Object inArgument)
public void networkEvent(Object obj)
Receive a network event from the system.
This method is used to receive network-related events from the system. To use this method, an application must first define a new unique EventType for the event. It must then define a new class that implements the Storable interface. One of the methods in the Storable interface is GetClassID. The ID returned from this method must be the EventType the application has defined. This is used by the system to map the EventType to a specific object. Finally, the application must use the RegisterHandler to register their new EventType with the system. When the network receives a network object, it calls the GetClassID method to determine which application to send the object to. It then calls the networkEvent method of the application with the object that had been received. Currently there can only be one registered receiver for the event.
Note: this method will be marked protected in
a future release.
obj - The object received over the network.EventTypepublic void resume()
public void suspend()
public void quit()
quit(int).
public void quit(int reason)
quit().
reason - why the app is being quit. One of:
QUIT_REASON_REBOOT,
QUIT_REASON_POWER_OFF,
QUIT_REASON_DISCARD,
QUIT_REASON_REMOVED,
QUIT_REASON_LOW_BATTERY,
QUIT_REASON_UNKNOWN.protected final void unload()
public void renderSplashScreen(View inView,
Pen inPen)
Display the application's splash screen.
This method is called when the application's icon is selected in the Chooser. Application's store their splash screen in the appropriate resource with the ID ID_SPLASH_SCREEN. Because of this the default method of renderSplashScreen can be used for all applications.
Note that in builds prior to the 2.3 release,
each call to renderSplashScreen() would receive the same
Pen to draw with.
You were supposed to redraw the entire Bitmap
with it, but if you didn't, whatever you drew last time would
still be there. If your drawing routine took a long time,
you had to be careful to avoid flicker because the launcher
might examine the Bitmap while you were in the middle of
drawing into it.
Beginning in the 2.3 release, the Pen provided is a
RecordingPen, which has a new and different
set of performance concerns. You no longer need worry about
flicker, because the Pen will not be redrawn until your
method returns. Overall system memory consumption should
be lower in general because there is no more need for a huge
backing bitmap for each application. However, if your
drawing routine does a huge number of individual operations,
each of those takes up a certain amount of storage and time, and if
you draw any Bitmaps you are urged to draw them from resources
(or from ImageView resources) if possible. See the javadoc
for RecordingPen for the details.
In the 2.3 release and later, any area of the splash screen where you do not draw anything will be filled with the generic background chiclets. If your splash screen design is suited to it and your application is only going to run on 2.3 or later devices, you are encouraged to draw only the foreground and to let the system draw the background for you.
Note: this method will be marked protected in a
future release. You should override, not call this method. To
update your splash screen, call updatePreviewScreen()
instead.
inView - a view with the bounds corresponding to the splash
screen. Generally, you will only use the view to obtain the
dimensions of the splash screen.inPen - the pen to use to draw the splash screen.
public void setSplashScreenSize(int width,
int height)
public void updatePreviewScreen()
Request that the system redisplay the application's splash screen.
This method sends an event to the system letting
it know that the splash screen has been changed, which will result
in a call to renderSplashScreen(danger.ui.View, danger.ui.Pen).
You should call, not override, this method.
public void updateIcons()
Notify the system that the application's icons have changed.
You should call, not override, this method.
public void setLargeIcon(Bitmap inIcon)
Generally, you will not need to use this method, as the large icon is automatically set to the ID_LARGE_ICON bitmap from your .rsrc file.
public void setSmallIcon(Bitmap inIcon)
Generally, you will not need to use this method, as the small icon is automatically set to the ID_LARGE_ICON bitmap from your .rsrc file.
public void setMiniIcon(Bitmap inIcon)
Generally, you will not need to use this method, as the mini icon is automatically set to the ID_MINI_ICON bitmap from your .rsrc file.
public void setChooserFolderLabel(CharSequence label)
null or "" will
clear out the label and the Chooser will simply show the
application title in its place.
label - The label to show for the application when it
is in a Chooser folder.public CharSequence getChooserFolderLabel()
protected void addQuickAccessItem(Bitmap bitmap,
CharSequence text,
Object data)
data - Arbitrary data that uniquely identifies a pending
item. Its entirely up to the application to decide how they
want to interpet this data.
When the user selects the item, the onQuickAccessItemSelected(java.lang.Object)
method will be invoked for the application.bitmap - null-ok; An icon for the item. The dimesnions of the
icon should not exceed those of the "small" application icon.text - non-null; Text for the item.
protected void addQuickAccessItem(Bitmap bitmap,
CharSequence text,
String uniqueID,
Object data)
uniqueID - non-null; unique identifier for the item.data - Arbitrary data that uniquely identifies a pending
item. Its entirely up to the application to decide how they
want to interpet this data.
When the user selects the item, the onQuickAccessItemSelected(java.lang.Object)
method will be invoked for the application.bitmap - null-ok; An icon for the item. The dimensions of the
icon should not exceed those of the "small" application icon.text - non-null; Text for the item.public void removeQuickAccessItem(String uniqueID)
onQuickAccessItemSelected(java.lang.Object) is invoked. However, you
will probably require to manually remove it as the pending
state of your application changes. For example, if the user
visits your app (independent of QuickAccess) and manipulates
data.
uniqueID - non-null; unique identifier for the item used in addQuickAccessItem(danger.ui.Bitmap, java.lang.CharSequence, java.lang.Object)public void removeQuickAccessItem(Object data)
onQuickAccessItemSelected(java.lang.Object) is invoked. However, you
will probably require to manually remove it as the pending
state of your application changes. For example, if the user
visits your app (independent of QuickAccess) and manipulates
data.
data - non-null; Arbitrary data used in addQuickAccessItem(danger.ui.Bitmap, java.lang.CharSequence, java.lang.Object)
public void removeQuickAccessItem(String uniqueID,
Object data)
onQuickAccessItemSelected(java.lang.Object) is invoked. However, you
will probably require to manually remove it as the pending
state of your application changes. For example, if the user
visits your app (independent of QuickAccess) and manipulates
data.
uniqueID - non-null; unique identifier for the item used in addQuickAccessItem(danger.ui.Bitmap, java.lang.CharSequence, java.lang.Object)data - non-null; Arbitrary data used in addQuickAccessItem(danger.ui.Bitmap, java.lang.CharSequence, java.lang.Object)public void removeAllQuickAccessItems()
onQuickAccessItemSelected(java.lang.Object) is invoked. However, you
will probably require to manually remove it as the pending
state of your application changes. For example, if the user
visits your app (independent of QuickAccess) and manipulates
data.
protected void onQuickAccessItemSelected(Object argument)
bringToForeground() is automatically called right
after this method executes.
argument - Arbitrary data given by the application when the
item was registered with addQuickAccessItem(danger.ui.Bitmap, java.lang.CharSequence, java.lang.Object)public void openURL(URL url)
Registrar.registerURLSchemeHandler(java.lang.String)
to register a URL
type that it handles (i.e. "date:", "phone:", etc), and the
system will then call this method when another application
trys to open a URL of this type. This is how the Calendar can
dial a phone number stored in an appointment.
url - The URL to be opened/handled.Registrarpublic void openURLInBackground(URL url)
Registrar.registerBackgroundURLSchemeHandler(java.lang.String)
to register a URL
type that it handles (i.e. "date:", "phone:", etc), and the
system will then call this method when another application
trys to open a URL of this type. This is how the Calendar can
dial a phone number stored in an appointment.
url - The URL to be opened/handled.Registrarpublic void bringToForeground()
public final void returnToLauncher()
public static Application getCurrentApp()
null when called in some system threads,
this should never return null from any user-created thread.
public static void launchApp(Bundle ai)
ai - An Bundle that contains reference information for the application.Bundlepublic static void setAppImpl(danger.app.AppImpl ai)
ai - An ApplImpl specifying the type of implementation (i.e. sim or dev).public Bundle getBundle()
public Window getFrontWindow()
public ScreenWindow getFrontScreenWindow()
public ResourceDatabase getResources()
public AlertWindow showAlert(int id)
public AlertWindow showAlert(int id,
Listener listener)
public AlertWindow getAlert(int id,
Listener listener)
public TextInputAlertWindow showTextInputAlert(int id,
Listener listener)
public TextInputAlertWindow getTextInputAlert(int id,
Listener listener)
public DialogWindow showDialog(int id,
Listener listener)
public DialogWindow getDialog(int id,
Listener listener)
public String getString(int id)
id - An int specifying the string to be returned.
public String getLocaleString(String locale,
int id)
locale - A String specifying the locale (ie. en_US, fr_CH, etc.)id - An int specifying the string to be returned.
public String[] getStringArray(int id)
id - an index specifying the string array to be returned.
public Bitmap getBitmap(int id)
id - An int specifying the bitmap to be returned.
public Resource getResource(int type,
int id)
type - An int specifying the type of resource to be returned.id - An int specifying the id of the resource to be returned.
public void hideActiveMenu()
public Event event(Listener target,
int type,
int what,
int data,
int modifiers,
int timestamp,
Object argument)
Event constructor with the same arguments,
except that the actual instance may have been recycled rather than
constructed afresh.
public Event event(Listener target,
int type,
int what,
int data,
Object argument)
Event constructor with the same arguments,
except that the actual instance may have been recycled rather than
constructed afresh.
public Event event(Listener target,
int type,
int what,
int data,
int modifiers)
Event constructor with the same arguments,
except that the actual instance may have been recycled rather than
constructed afresh.
public Event event(int type,
int what,
int data,
Object argument)
Event constructor with the same arguments,
except that the actual instance may have been recycled rather than
constructed afresh.
public Event event(int type,
int what,
int data)
Event constructor with the same arguments,
except that the actual instance may have been recycled rather than
constructed afresh.
public Event event(int type,
int what)
Event constructor with the same arguments,
except that the actual instance may have been recycled rather than
constructed afresh.
public Event event(int type)
Event constructor with the same arguments,
except that the actual instance may have been recycled rather than
constructed afresh.
public Event event()
Event constructor with the same arguments,
except that the actual instance may have been recycled rather than
constructed afresh.
public Event event(Listener target,
int type,
int what,
int data)
Event constructor with the same arguments,
except that the actual instance may have been recycled rather than
constructed afresh.
public Event event(Listener target,
int type,
int what)
Event constructor with the same arguments,
except that the actual instance may have been recycled rather than
constructed afresh.
public Event event(Listener target,
int type)
Event constructor with the same arguments,
except that the actual instance may have been recycled rather than
constructed afresh.
public Event event(Event orig)
Event constructor with the same arguments,
except that the actual instance may have been recycled rather than
constructed afresh.
public final Listener getNetworkListener()
protected void setNetworkListener(Listener networkListener)
networkListener - A Listener object that will receive application events.protected void setName(String appName)
appName - The new app name.protected void setShowInChooserMenu(boolean showInChooserMenu)
showInChooserMenu - Whether to show this app in the chooser menu or not.protected void setReceiveConnectivityEvents(boolean receiveConnectivityEvents)
EVENT_CONNECTION_UP
and EVENT_CONNECTION_DOWN events unless it has registered itself
as a handler for a network object. This function allows you to override that
setting.
receiveConnectivityEvents - true if you wish to receive
connectivity events; false if you do not.public void emptyTrash(String subTrash)
Override this method to empty the sub-trash with the specified
description. If subTrash is null, then the entire
trash for this application should be emptied.
This base class implementation does nothing. This method is called by the system if the user empties the trash from the Jump screen.
You specify sub-trash descriptions by using
GlobalTrash.setSubTrashContents(java.lang.String, java.lang.String). See the GlobalTrash
class for more details.
You should not play any sound (for example, the "empty trash" sound) as a result of this method call. The empty trash sound will be played automatically by the system.
subTrash - description of the sub-trash as specified by
a call to GlobalTrash.setSubTrashContents(java.lang.String, java.lang.String).
public static boolean registerForEvent(Listener inListener,
int event)
unregisterForEvent(danger.app.Listener, int) when you no longer want to
receive the event.
Returns false if the event type is not supported by this method.
Note that the active window always gets the following events, even if
it is not registered for the events using this method:
EventType.EVENT_HEADSET_STATUS,
EventType.EVENT_HINGE_CHANGED,
EventType.EVENT_NUM_ACTIVE_VOICE_CALLS_CHANGED.
Thus, for the above events, you only need to use this method if you
want to know about the events when you're not the active window.
inListener - the listener to receive the eventsevent - the type of event to listen to. Valid values are:
EventType.EVENT_POWER,
EventType.EVENT_TIME_CHANGED,
EventType.EVENT_TIME_FORMAT_CHANGED,
EventType.EVENT_PROFILE_CHANGED,
EventType.EVENT_ENTERING_KEY_GUARD,
EventType.EVENT_LEAVING_KEY_GUARD,
EventType.EVENT_SIM_PRESENCE,
EventType.EVENT_HEADSET_STATUS,
EventType.EVENT_CAMERA_STATUS,
EventType.EVENT_HINGE_CHANGED,
EventType.EVENT_NUM_ACTIVE_VOICE_CALLS_CHANGED,
EventType.EVENT_BACKLIGHT_CHANGED,
EventType.EVENT_ACTIVE_SPEAKER_CHANGED,
EventType.DEVICE_EXT_HOOK_UP,
EventType.DEVICE_EXT_HOOK_DOWN,
EventType.EVENT_AUDIO_MEDIA_VOLUME_CHANGED,
EventType.EVENT_AUDIO_MEDIA_VOLUME_CHANGE_REQUESTED,
EventType.EVENT_STORAGE_DEVICE_STATE_CHANGED,
EventType.EVENT_DATE_CHANGED.
Note that if you register for either
EventType.DEVICE_EXT_HOOK_UP or
EventType.DEVICE_EXT_HOOK_DOWN, you will receive both events.
public static boolean unregisterForEvent(Listener inListener,
int event)
registerForEvent(danger.app.Listener, int).
You do not need to call this simply to allow garbage collection.
registerForEvent(danger.app.Listener, int) uses a WeakReference, so as soon as you
no longer have a strong reference to the listener, it can be
garbage collected. After it is garbage collected, it will
automatically be unregistered for any events it was registered for.
Thus, you only need to make this call if you want to unregister
immediately.
Returns false if the event type is not supported by this method.
See registerForEvent(danger.app.Listener, int) for a list of valid event
values.
public static boolean registerForLeftShoulderHeld(String recipient,
IPCMessage msg,
int priority)
recipient - IPC service namemsg - the IPC message to send to the servicepriority - value used to settle conflicts. If two
apps both register for this left shoulder held case, then the one
with the higher priority wins. Third party apps calling
this method should use priorities less than 100.public static void unregisterForLeftShoulderHeld(String recipient)
recipient - IPC service nameregisterForLeftShoulderHeld(java.lang.String, danger.app.IPCMessage, int)public boolean wantsShiftKeyEnabledOutsideTextFields()
Specify whether this application wants to enable use of the shift key outside text edit fields. If true, then the user can enable shift and caps lock while focus is not on a text field. If false, use of the shift key is ignored while focus is not on a text field.
Currently, this returns true by default. It is recommended that if your app is particular about this setting, it should override this method and return the desired value explicitly, since the default value could change in a future OS release.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||