public class MainActivity
extends android.app.Activity
DEFAULT_KEYS_DIALER, DEFAULT_KEYS_DISABLE, DEFAULT_KEYS_SEARCH_GLOBAL, DEFAULT_KEYS_SEARCH_LOCAL, DEFAULT_KEYS_SHORTCUT, FOCUSED_STATE_SET, RESULT_CANCELED, RESULT_FIRST_USER, RESULT_OK
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, APP_OPS_SERVICE, APPWIDGET_SERVICE, AUDIO_SERVICE, BACKUP_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_NOT_VISIBLE, BIND_SHOWING_UI, BIND_VISIBLE, BIND_WAIVE_PRIORITY, BLUETOOTH_SERVICE, CAMERA_SERVICE, CAPTIONING_SERVICE, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONSUMER_IR_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, COUNTRY_DETECTOR, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_ROUTER_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NETWORK_POLICY_SERVICE, NETWORK_STATS_SERVICE, NETWORKMANAGEMENT_SERVICE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, PRINT_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, SERIAL_SERVICE, SIP_SERVICE, STATUS_BAR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, UI_MODE_SERVICE, UPDATE_LOCK_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
Constructor and Description |
---|
MainActivity() |
Modifier and Type | Method and Description |
---|---|
protected void |
onActivityResult(int requestCode,
int resultCode,
android.content.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.
|
void |
onBackPressed()
Called when the activity has detected the user's press of the back
key.
|
protected void |
onCreate(android.os.Bundle savedInstanceState)
Called when the activity is starting.
|
void |
onDestroy()
Perform any final cleanup before an activity is destroyed.
|
protected void |
onResume()
Called after
Activity.onRestoreInstanceState(android.os.Bundle) , Activity.onRestart() , or
Activity.onPause() , for your activity to start interacting with the user. |
void |
showMainMenu() |
addContentView, closeContextMenu, closeOptionsMenu, convertFromTranslucent, convertToTranslucent, createPendingResult, dismissDialog, dispatchGenericMotionEvent, dispatchKeyEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, dump, findViewById, finish, finishActivity, finishActivityFromChild, finishAffinity, finishFromChild, getActionBar, getActivityToken, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getCurrentFocus, getFragmentManager, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLoaderManager, getLocalClassName, getMenuInflater, getParent, getParentActivityIntent, getPreferences, getRequestedOrientation, getSystemService, getTaskId, getTitle, getTitleColor, getVolumeControlStream, getWindow, getWindowManager, hasWindowFocus, invalidateOptionsMenu, isChangingConfigurations, isChild, isDestroyed, isFinishing, isImmersive, isResumed, isTaskRoot, managedQuery, managedQuery, moveTaskToBack, navigateUpTo, navigateUpToFromChild, onActionModeFinished, onActionModeStarted, onApplyThemeResource, onAttachedToWindow, onAttachFragment, onChildTitleChanged, onConfigurationChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateNavigateUpTaskStack, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onCreateView, onDetachedFromWindow, onGenericMotionEvent, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onLowMemory, onMenuItemSelected, onMenuOpened, onNavigateUp, onNavigateUpFromChild, onNewIntent, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPause, onPostCreate, onPostResume, onPrepareDialog, onPrepareDialog, onPrepareNavigateUpTaskStack, onPrepareOptionsMenu, onPreparePanel, onProvideAssistData, onRestart, onRestoreInstanceState, onRetainNonConfigurationInstance, onSaveInstanceState, onSearchRequested, onStart, onStop, onTitleChanged, onTouchEvent, onTrackballEvent, onTrimMemory, onUserInteraction, onUserLeaveHint, onWindowAttributesChanged, onWindowFocusChanged, onWindowStartingActionMode, openContextMenu, openOptionsMenu, overridePendingTransition, recreate, registerForContextMenu, removeDialog, reportFullyDrawn, requestWindowFeature, runOnUiThread, setContentView, setContentView, setContentView, setDefaultKeyMode, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setFinishOnTouchOutside, setImmersive, setIntent, setPersistent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, shouldUpRecreateTask, showDialog, showDialog, startActionMode, startActivities, startActivities, startActivity, startActivity, startActivityAsUser, startActivityAsUser, startActivityForResult, startActivityForResult, startActivityFromChild, startActivityFromChild, startActivityFromFragment, startActivityFromFragment, startActivityIfNeeded, startActivityIfNeeded, startIntentSender, startIntentSender, startIntentSenderForResult, startIntentSenderForResult, startIntentSenderFromChild, startIntentSenderFromChild, startManagingCursor, startNextMatchingActivity, startNextMatchingActivity, startSearch, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenu
applyOverrideConfiguration, attachBaseContext, getResources, getTheme, getThemeResId, setTheme
bindService, bindServiceAsUser, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDisplayContext, createPackageContext, createPackageContextAsUser, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getBasePackageName, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getDisplayAdjustments, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getFilesDir, getFileStreamPath, getMainLooper, getObbDir, getObbDirs, getOpPackageName, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getSharedPreferences, getSharedPrefsFile, getUserId, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, registerReceiverAsUser, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setWallpaper, setWallpaper, startActivitiesAsUser, startInstrumentation, startService, startServiceAsUser, stopService, stopServiceAsUser, unbindService, unregisterReceiver
protected void onCreate(android.os.Bundle savedInstanceState)
android.app.Activity
Activity.setContentView(int)
to inflate the
activity's UI, using Activity.findViewById(int)
to programmatically interact
with widgets in the UI, calling
Activity.managedQuery(android.net.Uri , String[], String, String[], String)
to retrieve
cursors for data being displayed, etc.
You can call Activity.finish()
from within this function, in
which case onDestroy() will be immediately called without any of the rest
of the activity lifecycle (Activity.onStart()
, Activity.onResume()
,
Activity.onPause()
, etc) executing.
Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.
onCreate
in class android.app.Activity
savedInstanceState
- If the activity is being re-initialized after
previously being shut down then this Bundle contains the data it most
recently supplied in Activity.onSaveInstanceState(android.os.Bundle)
. Note: Otherwise it is null.Activity.onStart()
,
Activity.onSaveInstanceState(android.os.Bundle)
,
Activity.onRestoreInstanceState(android.os.Bundle)
,
Activity.onPostCreate(android.os.Bundle)
protected void onResume()
android.app.Activity
Activity.onRestoreInstanceState(android.os.Bundle)
, Activity.onRestart()
, or
Activity.onPause()
, for your activity to start interacting with the user.
This is a good place to begin animations, open exclusive-access devices
(such as the camera), etc.
Keep in mind that onResume is not the best indicator that your activity
is visible to the user; a system window such as the keyguard may be in
front. Use Activity.onWindowFocusChanged(boolean)
to know for certain that your
activity is visible to the user (for example, to resume a game).
Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.
onResume
in class android.app.Activity
Activity.onRestoreInstanceState(android.os.Bundle)
,
Activity.onRestart()
,
Activity.onPostResume()
,
Activity.onPause()
public void showMainMenu()
protected void onActivityResult(int requestCode, int resultCode, android.content.Intent data)
android.app.Activity
Activity.RESULT_CANCELED
if the activity explicitly returned that,
didn't return any result, or crashed during its operation.
You will receive this call immediately before onResume() when your activity is re-starting.
onActivityResult
in class android.app.Activity
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
- An Intent, which can return result data to the caller
(various data can be attached to Intent "extras").Activity.startActivityForResult(android.content.Intent, int)
,
Activity.createPendingResult(int, android.content.Intent, int)
,
Activity.setResult(int)
public void onBackPressed()
android.app.Activity
onBackPressed
in class android.app.Activity
public void onDestroy()
android.app.Activity
Activity.finish()
on it, or because the system is temporarily destroying
this instance of the activity to save space. You can distinguish
between these two scenarios with the Activity.isFinishing()
method.
Note: do not count on this method being called as a place for
saving data! For example, if an activity is editing data in a content
provider, those edits should be committed in either Activity.onPause()
or
Activity.onSaveInstanceState(android.os.Bundle)
, not here. This method is usually implemented to
free resources like threads that are associated with an activity, so
that a destroyed activity does not leave such things around while the
rest of its application is still running. There are situations where
the system will simply kill the activity's hosting process without
calling this method (or any others) in it, so it should not be used to
do things that are intended to remain around after the process goes
away.
Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.
onDestroy
in class android.app.Activity
Activity.onPause()
,
Activity.onStop()
,
Activity.finish()
,
Activity.isFinishing()