public class BaseListActivity
extends android.app.ListActivity
finish()
mechanism.
onResume()
method of subclasses of BaseActivity
should follow the template to support the chain of finish()
mechanism. See the description of onResume()
for details.
BaseActivity
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, AUDIO_SERVICE, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_NOT_FOREGROUND, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MODE_APPEND, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NOTIFICATION_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, TELEPHONY_SERVICE, UI_MODE_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
Constructor and Description |
---|
BaseListActivity() |
Modifier and Type | Method and Description |
---|---|
void |
exit()
Exit from this application.
|
boolean |
isStopping()
Check if this application is stopping or not.
|
protected void |
onResume()
Called when this Activity gets resumed.
|
void |
restart()
Restart this application.
|
getListAdapter, getListView, getSelectedItemId, getSelectedItemPosition, onContentChanged, onDestroy, onListItemClick, onRestoreInstanceState, setListAdapter, setSelection
addContentView, closeContextMenu, closeOptionsMenu, createPendingResult, dismissDialog, dispatchKeyEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, findViewById, finish, finishActivity, finishActivityFromChild, finishFromChild, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getCurrentFocus, getInstanceCount, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLocalClassName, getMenuInflater, getParent, getPreferences, getRequestedOrientation, getSystemService, getTaskId, getTitle, getTitleColor, getVolumeControlStream, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, getWindow, getWindowManager, hasWindowFocus, isChild, isFinishing, isTaskRoot, managedQuery, moveTaskToBack, onActivityResult, onApplyThemeResource, onAttachedToWindow, onBackPressed, onChildTitleChanged, onConfigurationChanged, onContextItemSelected, onContextMenuClosed, onCreate, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateOptionsMenu, onCreatePanelMenu, onCreatePanelView, onCreateThumbnail, onCreateView, onDetachedFromWindow, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyUp, onLowMemory, onMenuItemSelected, onMenuOpened, onNewIntent, onOptionsItemSelected, onOptionsMenuClosed, onPanelClosed, onPause, onPostCreate, onPostResume, onPrepareDialog, onPrepareDialog, onPrepareOptionsMenu, onPreparePanel, onRestart, onRetainNonConfigurationInstance, onSaveInstanceState, onSearchRequested, onStart, onStop, onTitleChanged, onTouchEvent, onTrackballEvent, onUserInteraction, onUserLeaveHint, onWindowAttributesChanged, onWindowFocusChanged, openContextMenu, openOptionsMenu, overridePendingTransition, registerForContextMenu, removeDialog, requestWindowFeature, runOnUiThread, setContentView, setContentView, setContentView, setDefaultKeyMode, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setIntent, setPersistent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, showDialog, showDialog, startActivity, startActivityForResult, startActivityFromChild, startActivityIfNeeded, startIntentSender, startIntentSenderForResult, startIntentSenderFromChild, startManagingCursor, startNextMatchingActivity, startSearch, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenu
bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getFileStreamPath, getMainLooper, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getWallpaper, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, revokeUriPermission, sendBroadcast, sendBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendStickyBroadcast, sendStickyOrderedBroadcast, setWallpaper, setWallpaper, startInstrumentation, startService, stopService, unbindService, unregisterReceiver
public boolean isStopping()
This method calls App.getInstance().
isStopping()
and returns its return value. In other words,
this method is an alias of App.getInstance().isStopping()
.
public void exit()
This method marks this application as stopping (by calling
App
.
getInstance()
.
setStopping
(true)
)
and closes this Activity (by calling Activity.finish()
).
If all Activities on the Activity stack honor the chain of
finish()
mechanism, all the Activities including
the root Activity will be finished.
The implementation of this method emits "STOPPING" log message.
public void restart()
This method marks this application as restarting (by calling
App
.
getInstance()
.
setRestarting
(true)
)
and closes this Activity (by calling Activity.finish()
).
If all Activities on the Activity stack honor the chain of
finish()
mechanism, all the Activities including
the root Activity will be finished.
BaseRootActivity
(or any Activity whose ListActivity.onDestroy()
does the same thing as BaseRootActivity
does), whose
onDestroy()
method checks whether the application is
in the process of restart (= whether App
.
getInstance()
.
isRestarting()
returns true
) and restarts the application
in that case. Restarting is performed by passing an Intent
with ACTION_MAIN
& CATEGORY_LAUNCHER
to
startActivity(Intent)
.
protected void onResume()
First, the implementation of onResume()
method of BaseListActivity
checks if this application is stopping. In other
words, the implementation checks if exit()
method of an
Activity on the stack above this Activity has been called. Then,
if the application is stopping, the implementation calls this.finish()
. This causes another Activity instance (which is
right under this Activity instance on the stack) that belongs to
the application to get resumed. It is expected that the onResume()
instance of the next Activity is implemented like
the following in order to let the application finish gracefully.
super.onResume(); // Check if the application is stopping. if (isStopping()) { // finish() has already been called in super.onResume() // (if this Activity is a subclass of Base*Activity), so // leave this Activity without doing anything. This chain // of finish() will finally reach the root Activity. return; } // Code specific to this Activity. ......
onResume
in class android.app.Activity
Copyright © 2016. All rights reserved.