java.lang.Object | |
↳ | com.neomades.app.Application |
Inherit that class to set the entry point of the application.
By overriding the onStart(Controller)
method, the application says
what screen should be pushed on start.
For example, an application which wants to show a Splash screen :
public class MyApplication extends Application { public void onStart(Controller controller) { controller.pushScreen(SplashScreen.class); } }
Each NeoMAD application has single instance of Application
.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | PROXIMITY_ENTER_REGION | Key indicating that the terminal is entering a proximity region. | |||||||||
int | PROXIMITY_EXIT_REGION | Key indicating that the terminal is exiting a proximity region. | |||||||||
int | PUSH_FAILURE | The registration has failed. | |||||||||
int | PUSH_REGISTERED | The device is registered in the OS Push Notification server. | |||||||||
int | PUSH_SERVICE_CHANGED_ID | The registration has changed the device registration unique Identifier. | |||||||||
int | PUSH_UNREGISTERED | The device has been unregistered from the server. | |||||||||
int | THEME_DARK | Black or Dark theme | |||||||||
int | THEME_LIGHT | White or Light theme |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
protected final Controller | controller |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Application()
Do not override this constructor.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
exit()
Try or Ask to exit the application.
| ||||||||||
ContentManager |
getContentManager()
Gets the registered content manager.
| ||||||||||
static Application |
getCurrent()
Returns the current instance of the application.
| ||||||||||
EventBus | getEventBus() | ||||||||||
String |
getName()
Returns the Application name.
| ||||||||||
String |
getPackageName()
Returns the main package name of the application.
| ||||||||||
final boolean | isActivated() | ||||||||||
final boolean | isBackground() | ||||||||||
boolean |
isCreated()
Returns if the Application has been created.
| ||||||||||
final boolean | isDeactivated() | ||||||||||
final boolean | isForeground() | ||||||||||
boolean |
isStarted()
Returns if the Application has started and should be ready to show to a
screen
| ||||||||||
void |
openURL(String url)
Attempts to open the resource at the specified URL.
| ||||||||||
void | registerContentManager(ContentManager manager) | ||||||||||
void |
setApplicationDelegate(ApplicationDelegate delegate)
Sets a specific application delegate.
| ||||||||||
void |
setBadgeNumber(int number)
Sets the badge number displayed over the application icon (iOS)
| ||||||||||
void |
startVoiceCall(String phoneNumber)
Starts a voice call to a phone number.
| ||||||||||
void | unregisterContentManager(ContentManager manager) |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
final Controller | getController() | ||||||||||
void |
onActivated()
Called when the application will be activated (after
onStart(Controller) ). | ||||||||||
void |
onBackground()
Called when the application goes in background.
| ||||||||||
boolean |
onBeforeExit(Controller controller)
Override this method to provide a behavior when the application is about to
exit.
| ||||||||||
void |
onCreate(Controller controller)
Called before
onStart(Controller) method. | ||||||||||
void |
onDeactivated()
Called when the application will be deactivated.
| ||||||||||
void |
onExit()
Called when the application exits (just before the process is killed by the
system).
| ||||||||||
void |
onForeground()
Called when the application goes in foreground.
| ||||||||||
void |
onHandlePushMessage(String payload)
This method is deprecated.
see
onPushMessageReceived(PushMessage) and
Application onPushMessageReceived(PushMessage)
| ||||||||||
void |
onLocalNotificationReceived(Notification notification)
Automatically called when the end-user clicks on a local
Notification . | ||||||||||
void |
onProximityChanged(Location myLocation, ProximityRegion region, int status)
This method will be called when proximity to registered coordinates is
detected.
| ||||||||||
void |
onPushMessageReceived(PushMessage message)
Called when the end-user has clicked a Push-Notification.
| ||||||||||
void |
onPushRegistrationChanged(int status, String message)
Called when the push registration status has changed.
| ||||||||||
abstract void |
onStart(Controller controller)
Override this method to provide a behavior when starting the application :
for example push the main screen in this method
| ||||||||||
final void |
setActionBarEnabled(boolean enabled)
Set the android ActionBar mode enabled or not.
| ||||||||||
final void |
setActionBarTheme(int nativeTheme)
Sets a native theme type (light or dark) to use in the action bar for this
application.
| ||||||||||
final void |
setBackButtonText(String backButtonText)
Replaces the "Back" button text.
| ||||||||||
final void |
setBackButtonTextColor(Color backButtonTextColor)
Changes the "Back" button text color.
| ||||||||||
void | setEventBusEnabled(boolean on) | ||||||||||
final void |
setForcedTheme(int nativeTheme)
Sets a native theme type (light or dark) to use for this application.
| ||||||||||
final void |
setSupportedOrientation(int orientation)
Forces the application to be in portrait and/or landscape mode.
| ||||||||||
final void |
setTitleBackground(Background background)
Sets the title bar background.
| ||||||||||
final void |
setTitleBackgroundColor(Color bgColor)
Sets the title bar background color.
| ||||||||||
final void |
setTitleBackgroundImage(Image image)
Sets the title bar background image.
| ||||||||||
final void |
setTitleBackgroundImage(int resImage)
Sets the title bar background image.
| ||||||||||
final void |
setTitleColor(Color titleColor)
Sets the title text color.
| ||||||||||
final void |
setTitleFont(Font font)
Sets the title font.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Key indicating that the terminal is entering a proximity region.
Key indicating that the terminal is exiting a proximity region.
The registration has failed. See message parameter to get details of the failure.
The device is registered in the OS Push Notification server.
The registration has changed the device registration unique Identifier.
The device has been unregistered from the server.
Black or Dark theme
White or Light theme
Do not override this constructor.
Do not call this constructor.
Try or Ask to exit the application.
Not supported on iOS.
com.neomades.mad.TargetInfo#HAS_EXIT_FEATURE
TargetInfo.HAS_EXIT_FEATURE could be used to put a condition around usage of
this method.
The controller will check whether the application is authorized to exit, by
calling onBeforeExit(Controller)
method and the response of this
method will authorize to exit or not.
onBeforeExit(Controller)
Gets the registered content manager.
null
.
Returns the current instance of the application.
Returns the main package name of the application.
Be careful with the returned value and the URS Application identifier. This package could be different at runtime from the source code if an Application identifier is set in the URS file.
Returns if the Application has been created.
onCreate(Controller)
method or is already created.Returns if the Application has started and should be ready to show to a screen
onStart(Controller)
method or is already started.Attempts to open the resource at the specified URL.
If the URL is a "resource" on the World Wide Web, the application will open the browser at the specified URL.
If the url starts with file://
, it will try to open the file
installed at the path specified after file://
using the default
application that can open the file depending on its extension.
url | the URL to open |
---|
IllegalArgumentException | if the file does not exist or is a directory |
---|
Sets a specific application delegate. Setting an ApplicationDelegate might be useful in very specific case when the application uses the NeoMAD specific code feature. This will enable to access the native application instance in the specific code.
Use this method inside your application's onCreate(Controller)
method.
delegate | a delegate or null |
---|
Sets the badge number displayed over the application icon (iOS)
number | a positive non-zero integer to show badge. |
---|
Starts a voice call to a phone number.
To use this method, the PHONE_CALL permission must be declared in the URS file.
phoneNumber | the phone number to call |
---|
Called when the application will be activated (after
onStart(Controller)
).
Called when the application goes in background.
Override this method to provide a behavior when the application is about to exit. For example save the state of the application or ask confirmation.
controller | the controller of this application |
---|
Called before onStart(Controller)
method.
The onStart(Controller)
is not necessary called after this method.
For example, a click over Notification
could launch the application.
public MyApplication extends Application implements PushServiceListener, PushMessageListener { protected void onCreate(Controller controller) { PushServiceManager pushService = PushServiceManager.getDefault(); // Register the push service if not registered pushService.register(); } protected void onPushMessageReceived(PushMessage message) { // called when a push notification is clicked by the end-user } protected void onPushRegistrationChanged(int status, String message) { if (status == REGISTERED) { // the push service is ready // send to the application server the current ID // by HTTP String id = message; // After now, the service currentID could be get also by PushServiceManager.getDefault().getCurrentID(); // ... } else if (status == SERVICE_CHANGED_ID) { // the push service has changed the ID String newId = message; } else if (status == UNREGISTERED) { // the push service has unregistered this device } else if (status == FAILURE) { String details = message; } } }
Warning: This method is called before onStart(Controller)
.
The application could be started by a Push-Notification
or by
the end-user. The onStart(Controller)
method is called after only if
the user has launched manually the application.
Called when the application will be deactivated.
Called when the application exits (just before the process is killed by the system).
Called when the application goes in foreground.
This method is deprecated.
see onPushMessageReceived(PushMessage)
and
Application
onPushMessageReceived(PushMessage)
Handles a Push-Notification message received from the server before showing it.
This handler replaces the default android visual Notification in the notification Bar.
NB. if the notification has a "notification" section (see
PushMessage
), this callback will not be called.
Only called in android.
payload | the message payload data. See details in PushMessage . |
---|
Automatically called when the end-user clicks on a local
Notification
.
notification | the clicked notification |
---|
This method will be called when proximity to registered coordinates is detected. It could be called if the terminal enters or exits the given ProximityRegion. Override this method in your Application class to make the required treatments A proximity event could also wake up a not-running application on Android and iOS platforms.
myLocation | the current location |
---|---|
region | the defined proximity region. |
status | an integer indicating whether the terminal is entering or exiting the defined region. |
Called when the end-user has clicked a Push-Notification.
message | the clicked message |
---|
Called when the push registration status has changed.
status
is PUSH_REGISTERED
, the
message
contains the service currentID
(same value
as getCurrentID()
)status
is PUSH_SERVICE_CHANGED_ID
, the
message
contains the new service currentID
(same value as getCurrentID()
)status
is PUSH_UNREGISTERED
, the
message
contains the details of the statestatus
is PUSH_FAILURE
, the
message
contains the details of the failurestatus | the new status |
---|---|
message | the details attached with the status. |
Override this method to provide a behavior when starting the application : for example push the main screen in this method
controller | the controller of this application |
---|
Set the android ActionBar mode enabled or not.
By default, the action bar is enabled.
enabled | true to set enabled the action bar. |
---|
Sets a native theme type (light or dark) to use in the action bar for this application.
This method should be call at the beginning of the
onStart(Controller)
method.
nativeTheme | THEME_DARK or THEME_LIGHT |
---|
Replaces the "Back" button text.
This method must be called into onStart(Controller)
method in order
to keep the same back button text during the navigation.
On iOS it changes the left back button of the navigation bar.
On Android this method does nothing.
IllegalStateException | If this method is called outside onStart(Controller)
method.
|
---|
Changes the "Back" button text color.
This method must be called into onStart(Controller)
method in order
to keep the same back button text color during the navigation.
On iOS it changes the left back button text color of the navigation bar.
On Android this method does nothing.
IllegalStateException | If this method is called outside onStart(Controller)
method.
|
---|
Sets a native theme type (light or dark) to use for this application.
This method should be call at the beginning of the
onStart(Controller)
method.
Not supported on iOS platform.
nativeTheme | THEME_DARK or THEME_LIGHT |
---|
Forces the application to be in portrait and/or landscape mode. This method does nothing if the device cannot handle orientation changing.
By default, the requested orientation is AUTO
which
means PORTRAIT
and LANDSCAPE
On some platforms, the orientation cannot be changed once a screen has been pushed to the display. So, this method should be called before any screen is pushed (at the beginning of the Application.onStart() for example).
orientation | the requested orientation (AUTO by
default) |
---|
Sets the title bar background.
This method must be called into onStart(Controller)
method.
background | the background of the title bar |
---|
IllegalStateException | If this method is called outside onStart(Controller)
method.
|
---|
Sets the title bar background color.
This method must be called into onStart(Controller)
method.
bgColor | the background color of the title bar |
---|
IllegalStateException | If this method is called outside onStart(Controller)
method.
|
---|
Sets the title bar background image.
This method must be called into onStart(Controller)
method.
image | the background image of the title bar |
---|
IllegalStateException | If this method is called outside onStart(Controller)
method.
|
---|
Sets the title bar background image.
This method must be called into onStart(Controller)
method.
resImage | the background image of the title bar |
---|
IllegalStateException | If this method is called outside onStart(Controller)
method.
|
---|
Sets the title text color.
This method must be called into onStart(Controller)
method.
titleColor | the color for the title |
---|
IllegalStateException | If this method is called outside onStart(Controller)
method.
|
---|
Sets the title font.
This method must be called into onStart(Controller)
method.
font | the font for the title |
---|
IllegalStateException | If this method is called outside onStart(Controller)
method.
|
---|