danger.app
Class Application
java.lang.Object
|
+--danger.app.Listener
|
+--danger.app.Application
- public class Application
- extends Listener
Application interface to the Application class
This class is extended by all applications.
|
Constructor Summary |
Application()
Constructs a new Application object. |
|
Method Summary |
void |
bringToForeground()
Bring yourself to the foreground. |
static void |
checkSecurityIsSysApp()
|
StandardAlertWindow |
getAlert(int id,
Listener listener)
|
Bitmap |
getBitmap(int id)
Get a bitmap from the resource database. |
Bundle |
getBundle()
Get the application information. |
static Application |
getCurrentApp()
Get the current application. |
DialogWindow |
getDialog(int id,
Listener listener)
|
Window |
getFrontWindow()
Get the frontmost, visible window that belongs to this application. |
java.lang.String |
getLocaleString(java.lang.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()
RESERVED: Get the shadow for the current application. |
java.lang.String |
getString(int id)
Get a string resource from the resource database. |
java.lang.String[] |
getStringArray(int id)
Get a string array resource from the resource database. |
void |
handleLauncherMenuShortcut(char inChar)
|
void |
hideActiveMenu()
|
void |
hideActiveMenuIfOrphaned()
|
static void |
launchApp(Bundle ai)
Launch the specified application. |
void |
networkEvent(java.lang.Object obj)
RESERVED: Receive a network event from the system. |
void |
openURL(URL url)
Receive and handle a URL based request. |
void |
paintSplashScreen()
RESERVED: Redisplay the application's splash screen. |
void |
quit()
Quit the application. |
boolean |
receiveEvent(Event e)
Receive a new event. |
void |
receiveMessage(int inMessage,
int inData,
java.lang.Object inArgument)
Receive a message from the system. |
void |
renderSplashScreen(View inView,
Pen inPen)
RESERVED: Display the application's splash screen. |
void |
resume()
Resume the application. |
void |
returnToLauncher()
Return to the Chooser. |
void |
setActiveMenu(BaseMenu activeMenu)
|
static void |
setAppImpl(danger.app.AppImpl ai)
Set the application implementation for this application. |
protected void |
setName(java.lang.String appName)
Change the name of an application. |
protected void |
setNetworkListener(Listener networkListener)
Set the current listener for network events. |
void |
setShadow(Shadow s)
RESERVED: Set the shadow for the current application. |
protected void |
setShowInChooserMenu(boolean showInChooserMenu)
Control whether the application appears in the chooser menu. |
StandardAlertWindow |
showAlert(int id)
|
StandardAlertWindow |
showAlert(int id,
Listener listener)
|
DialogWindow |
showDialog(int id,
Listener listener)
|
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 |
void |
updatePreviewScreen()
RESERVED: Redisplay the application's splash screen. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Application
public Application()
- Constructs a new Application object.
This method creates and registers a new application with
the system. It also attaches the new object to the window
manager.
receiveEvent
public boolean receiveEvent(Event e)
- Receive a new event.
This is the main method for receiving events from the system.
If the method returns true, the system assumes the event has
been handled and does not further processing. If the method
returns false, the system does its default processing on the
event.
- Overrides:
receiveEvent in class Listener
- Parameters:
e - An Event object containing the event type and data.- Returns:
- A boolean that is true if the method handled the event.
handleLauncherMenuShortcut
public void handleLauncherMenuShortcut(char inChar)
receiveMessage
public void receiveMessage(int inMessage,
int inData,
java.lang.Object inArgument)
- Receive a message from the system.
This method is used to receive messages from the system. The
inMessage parameter contains the type of the message being
received. The contents of the inData and inArgument parameters
are dependent on the type of message being received.
- Parameters:
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.
networkEvent
public void networkEvent(java.lang.Object obj)
- RESERVED: 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.
- Parameters:
obj - The object received over the network.- See Also:
EventType
resume
public void resume()
- Resume the application.
Called whenever the application is selected from the Chooser.
suspend
public void suspend()
- Suspend the application.
Called whenever the user returns to the Chooser from an application.
quit
public void quit()
- Quit the application.
Called whenever the application needs to quit. This happens
when the system software is being update, when a low-power
condition has occured, or when the device is being rebooted.
unload
protected final void unload()
- Should be the last thing called as a response to quit()
- this will abort() the app's dispatcher and finalize unloading
renderSplashScreen
public void renderSplashScreen(View inView,
Pen inPen)
- RESERVED: 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_SplashScreen. Because
of this the default method of RenderSplashScreen can be used
for all applications.
updatePreviewScreen
public void updatePreviewScreen()
- RESERVED: Redisplay the application's splash screen.
This method sends an event to the current application letting
it know that the splash screen has been changed.
paintSplashScreen
public void paintSplashScreen()
- RESERVED: Redisplay the application's splash screen.
This method uses RenderSplashScreen to actually paint the
splash screen, then sends an event to the application letting
it know that the splash screen has been painted.
openURL
public void openURL(URL url)
- Receive and handle a URL based request.
Works as an IPC mechanism between applications. An application
can use the RegisterURLSchemeHandler method 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.
- Parameters:
url - The URL to be opened/handled.- See Also:
Registrar
bringToForeground
public void bringToForeground()
- Bring yourself to the foreground.
Causes your application's Resume method to be called as if it
were being run from the Chooser.
returnToLauncher
public final void returnToLauncher()
- Return to the Chooser.
Causes your application's Suspend method to be called and then returns
the user to the Chooser.
getCurrentApp
public static Application getCurrentApp()
- Get the current application.
Gets a reference to the currently running application. Applications may
use this method to reference their application object from methods where
it is not readily available through member variables.
- Returns:
- An Application that references the currently running application.
checkSecurityIsSysApp
public static void checkSecurityIsSysApp()
launchApp
public static void launchApp(Bundle ai)
- Launch the specified application.
Launch the application specified in the parameter.
- Parameters:
ai - An Bundle that contains reference information for the application.- See Also:
Bundle
setAppImpl
public static void setAppImpl(danger.app.AppImpl ai)
- Set the application implementation for this application.
The AppImpl is an abstract class containing the implementation-specific
methods for an application. These are the methods that are different on
the simulator versus the actual device.
- Parameters:
ai - An ApplImpl specifying the type of implementation (i.e. sim or dev).
getBundle
public Bundle getBundle()
- Get the application information.
Returns the Bundle associated with this application. The Bundle contains
the application name, class name, hotkey, and other information related to
the application.
- Returns:
- An Bundle object containing the application information.
getFrontWindow
public Window getFrontWindow()
- Get the frontmost, visible window that belongs to this application.
Returns the frontmost window that is visible and belongs to this
application. Returns null if no windows are visible.
- Returns:
- A Window containing the frontmost window.
getResources
public ResourceDatabase getResources()
- Get the resource database associated with this application.
Returns the resource database that belongs to this application.
- Returns:
- A ResourceDatabase containing the resource database.
showAlert
public StandardAlertWindow showAlert(int id)
showAlert
public StandardAlertWindow showAlert(int id,
Listener listener)
getAlert
public StandardAlertWindow getAlert(int id,
Listener listener)
showDialog
public DialogWindow showDialog(int id,
Listener listener)
getDialog
public DialogWindow getDialog(int id,
Listener listener)
getString
public java.lang.String getString(int id)
- Get a string resource from the resource database.
Returns a string from the resource database for the application. The string
to return is specified by the id parameter. If no string with the given id
is found, the method returns null.
- Parameters:
id - An int specifying the string to be returned.- Returns:
- A String containing the specified string or null.
getLocaleString
public java.lang.String getLocaleString(java.lang.String locale,
int id)
- Get a localized string resource from the resource database.
Returns a string from the resource database for the application. The string
to return is specified by the id parameter. If no resource database for the given
locale is available the method returns null. If no string with the given id
is found in the database the method returns null.
- Parameters:
locale - A String specifying the locale (ie. en_US, fr_CH, etc.)id - An int specifying the string to be returned.- Returns:
- A String containing the specified string or null.
getStringArray
public java.lang.String[] getStringArray(int id)
- Get a string array resource from the resource database.
Returns a string array from the resource database for the application. The string
array to return is specified by the id parameter. If no string array with the given id
is found, the method returns null.
- Parameters:
inKey - A string specifying the string array to be returned.- Returns:
- A String[] containing the specified string array or null.
getBitmap
public Bitmap getBitmap(int id)
- Get a bitmap from the resource database.
Returns a bitmap from the resource database for the application. The bitmap
to return is specified by the id parameter. If no bitmap with the given id
is found, the method returns null.
- Parameters:
id - An int specifying the bitmap to be returned.- Returns:
- A Bitmap containing the specified bitmap or null.
getResource
public Resource getResource(int type,
int id)
- Get a resource from the resource database.
Returns a resource from the resource database for the application. The type
and id of the resource to get are specified in the type and id parameters.
If no resource of the specified type with the given id is found, the method
returns null.
- Parameters:
type - An int specifying the type of resource to be returned.id - An int specifying the id of the resource to be returned.- Returns:
- A Resource containing the specified resource or null.
getShadow
public Shadow getShadow()
- RESERVED: Get the shadow for the current application.
Returns the Shadow object for the given application. This object contains
WindowManager-specific information that cannot be reference by other classes.
setShadow
public void setShadow(Shadow s)
- RESERVED: Set the shadow for the current application.
Sets the Shadow object for the given application. This object contains
WindowManager-specific information that cannot be reference by other classes.
The Shadow is installed during Application construction and cannot be changed
afterwards.
- Parameters:
s - A Shadow to be installed during application construction.
setActiveMenu
public void setActiveMenu(BaseMenu activeMenu)
hideActiveMenu
public void hideActiveMenu()
hideActiveMenuIfOrphaned
public void hideActiveMenuIfOrphaned()
getNetworkListener
public final Listener getNetworkListener()
- Get the current listener for network events.
Returns the Listener associated with this application. The Listener is the
object that receives network events for the application. The Listener object can
be executed in a different thread than the application. If no listener is
specified, events are sent to the Application object.
- Returns:
- A Listener object.
setNetworkListener
protected void setNetworkListener(Listener networkListener)
- Set the current listener for network events.
Sets the Listener associated with this application. The Listener is the
object that receives network events for the application. The Listener object can
be executed in a different thread than the application. If no listener is
specified, events are sent to the Application object.
- Parameters:
networkListener - A Listener object that will receive application events.
setName
protected void setName(java.lang.String appName)
- Change the name of an application.
The name of an app should be suitable for display in the Launcher,
and other human-readable places.
- Parameters:
appName - The new app name.
setShowInChooserMenu
protected void setShowInChooserMenu(boolean showInChooserMenu)
- Control whether the application appears in the chooser menu.
Note that this only works for apps also marked Invisible ('I') in
the ID_AppFlags section of their resources.
- Parameters:
showInChooserMenu - Whether to show this app in the chooser menu or not.
Danger Confidential. Copyright © 2000-2003, Danger Inc.