|
||||||||||
| 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.
| 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. |
boolean |
allowEntryInSystemLock()
Override to allow this app to be active in system lock. |
void |
bringToForeground()
Bring yourself to the foreground. |
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. |
Shadow |
getShadow()
Deprecated. For internal use only. |
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 |
paintSplashScreen()
Deprecated. Override renderSplashScreen(danger.ui.View, danger.ui.Pen) if using a
splash screen resource is insufficient. |
void |
quit()
Quit the application. |
boolean |
receiveEvent(Event e)
Receive a new event. |
void |
receiveMessage(int inMessage,
int inData,
Object inArgument)
Receive a message from the system. |
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 |
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. |
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)
Control whether the application appears in the chooser menu. |
void |
setSmallIcon(Bitmap inIcon)
Set the small icon for this application. |
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. |
| 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 |
| Constructor Detail |
|---|
public Application()
| Method Detail |
|---|
public boolean receiveEvent(Event e)
receiveEvent in class Listenere - An Event object containing the event type and data.
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)
inMessage - An int containing the type of message being received.inData - An int containing data associated with the message.inArgument - An Object containing an object associated with the message.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()
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 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 paintSplashScreen()
renderSplashScreen(danger.ui.View, danger.ui.Pen) if using a
splash screen resource is insufficient.
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.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 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)
url - The URL to be opened/handled.Registrarpublic void openURLInBackground(URL url)
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 final Shadow getShadow()
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 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_PREFERENCES_CHANGED,
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.
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)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||