|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectActivity
org.hermit.android.core.MainActivity
public class MainActivity
An enhanced Activity class, for use as the main activity of an application. The main thing this class provides is a nice callback-based mechanism for starting sub-activities. This makes it easier for different parts of an app to kick off sub-activities and get the results.
Note: it is best that sub-classes do not implement onActivityResult(int, int, Intent). If they do, then for safety use small request codes, and call super.onActivityResult(int, int, Intent) when you get an unknown code.
Nested Class Summary | |
---|---|
static class |
MainActivity.ActivityListener
This interface defines a listener for sub-activity results. |
Constructor Summary | |
---|---|
MainActivity()
|
Method Summary | |
---|---|
void |
createEulaBox(int title,
int text,
int close)
Create a dialog for showing the EULA, or other warnings / disclaimers. |
void |
createMessageBox(int close)
Deprecated. The message box is now created automatically. |
protected void |
onActivityResult(int requestCode,
int resultCode,
Intent data)
Called when an activity you launched exits, giving you the requestCode you started it with, the resultCode it returned, and any additional data from it. |
protected void |
onCreate(Bundle icicle)
Called when the activity is starting. |
void |
reportException(java.lang.Exception e)
Report an unexpected exception to the user by popping up a dialog with some debug info. |
void |
setAboutInfo(int about)
Set up the about info for dialogs. |
void |
setHomeInfo(int link)
Set up the homepage info for dialogs. |
void |
setHomeInfo(int button,
int link)
Deprecated. |
void |
setLicenseInfo(int link)
Set up the license info for dialogs. |
void |
setLicenseInfo(int button,
int link)
Deprecated. |
void |
showAbout()
Show an about dialog. |
void |
showEula()
Show the EULA dialog unconditionally. |
void |
showFirstEula()
Show the EULA dialog if this is the first program run. |
void |
startActivityForResult(Intent intent,
MainActivity.ActivityListener listener)
Launch an activity for which you would like a result when it finished. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MainActivity()
Method Detail |
---|
protected void onCreate(Bundle icicle)
icicle
- If the activity is being re-initialised
after previously being shut down then this
Bundle contains the data it most recently
supplied in onSaveInstanceState(Bundle).
Note: Otherwise it is null.public void createEulaBox(int title, int text, int close)
showFirstEula()
to display
the dialog the first time your app runs. To display it on demand,
call showEula()
.
title
- Resource ID of the dialog title.text
- Resource ID of the EULA / warning text.close
- Resource ID of the close button.public void showFirstEula()
createEulaBox(int, int, int)
.
public void showEula()
createEulaBox(int, int, int)
.
@Deprecated public void createMessageBox(int close)
setHomeInfo(int, int)
, setAboutInfo(int)
and
setLicenseInfo(int, int)
; then pop up a dialog by calling
showAbout()
.
close
- Resource ID of the close button.public void setAboutInfo(int about)
showAbout()
.
about
- Resource ID of the about text.public void setHomeInfo(int link)
showAbout()
.
link
- Resource ID of the URL the button links to.@Deprecated public void setHomeInfo(int button, int link)
showAbout()
.
button
- Resource ID of the button text.link
- Resource ID of the URL the button links to.public void setLicenseInfo(int link)
showAbout()
.
link
- Resource ID of the URL the button links to.@Deprecated public void setLicenseInfo(int button, int link)
showAbout()
.
button
- Resource ID of the button text.link
- Resource ID of the URL the button links to.public void showAbout()
setAboutInfo(int)
, setHomeInfo(int, int)
and setLicenseInfo(int, int)
.
public void reportException(java.lang.Exception e)
This method may be called from any thread. The reporting will be deferred to the UI thread.
e
- The exception.public void startActivityForResult(Intent intent, MainActivity.ActivityListener listener)
Note that this method should only be used with Intent protocols that are defined to return a result. In other protocols (such as ACTION_MAIN or ACTION_VIEW), you may not get the result when you expect. As a special case, if you call startActivityForResult() during the initial onCreate() / onResume() of your activity, then your window will not be displayed until a result is returned back from the started activity. This method throws ActivityNotFoundException if there was no Activity found to run the given Intent.
intent
- The intent to start.listener
- Listener to invoke when the activity returns.protected void onActivityResult(int requestCode, int resultCode, Intent data)
requestCode
- The integer request code originally supplied
to startActivityForResult(), allowing you to
identify who this result came from.resultCode
- The integer result code returned by the child
activity through its setResult().data
- Additional data to return to the caller.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |