一、繼承結構
? ? java.lang.object-->android.content.Context-->android.content.ContextWrapper-->android.view.ContextThemeWrapper-->android.app.Activity
二、所有已實現的接口
ComponentCallbacks,keyEvent.Callback,LayoutInflater.Factory,View.OnCreateContextMenuListener,Window.Callback
三、直接已知子類
ActivityGroup,AliasActivity,ExpandableListActivity,ListActivity
翻譯:
public class?Activity?extends?ContextThemeWrapper?implements?LayoutInflater.Factory,Window.Callback,KeyEvent.Callback,View.OnCreateContextMenuListener,ComponentCallbacks
一個activity是一個單例,用戶能夠在上面處理一些事情。幾乎所有的activites都與用戶進行互動,因此Activity類使用方法setContentView(int)放置UI組件到創建的窗口上。與此同時,activies通常以全屏的形式展現在windows上,也可以使用其他的方法,例如漂浮在window上(通過theme使用andorid.R.attr#windowIsFloating 設置)或者嵌入到其他的acticity(使用ActivityGroup).Activity的子類需要實現至少兩種方法
onCreate(andorid.os,Bundle)用來初始化你的activity.最重要的是,在這里你通常調用setContentView(int)方法來布置你的資源文件到UI上,且使用findViewById(int)來檢索widgets中的UI,你能夠使用帶來來進行互動。
onPause()用來處理用戶離開activity。最重要的,任何由用戶進行的改變在此時被確認(通常到ContentProvider保持數據)
使用Context.startActivity(),所有的activity類必須有一個相應的<activity>在AndoridManifest.xml中聲明。
Activity類在應用的整個生命周期中是很重要的一部分,activitys的簡歷和整合是應用模型平臺的一個基礎功能。關于安卓應用數據結構的詳細觀點,請閱讀Dev Guid文檔在Application Fundamentals.
Topics covered here:
3、Starting Activities and Getting Results
1 Activity Lifecycle
所有的系統中的Activities以activity stack(棧)的形式管理。當一個activity啟動后,它被放置在棧的最頂端,且成為運行中的activity----之前的activity通常放置在棧的下邊,在新的activity存在的情況下是不會出現到前臺的。
一個activity具有四個本質特點
如果activity在屏幕的前端,他處于被激活或者運行狀態。
如果activity失去焦點,但是仍然可見(就是一個新的非全屏尺寸或者轉場的activity在你的activity之上獲取焦點),他會暫停。一個暫停的activity是完全活著的(他保持所有的狀態和成員信息且依然接近window管理者),但是可能被紫銅在低內存狀態下殺死。
如果activity被另一個activity完全遮蔽,他就會停止。他依然會保持所有的狀態和成員信息,然而他對用戶不在可見,因此他的窗口時隱藏的而且當任何地方需要內存的時候,系統會將其殺死。
如果activity暫停或者停止,系統會從內存中拋棄activiy通過要求他結束,或者僅僅殺死這個進程。當他再次展示的時候,他必須是完全重啟且存儲他之前的狀態。
下面的項目展示了activity的重要狀態路徑。廣場的正方形代表了回調方法你能實現,來展示運算當activity在兩種狀態之間移動。帶顏色的主要狀態是activity能夠進入。
在你監視你的activity的時候,你可能感興趣的有三個關鍵的loops。
整個activity的生命周期,從第一次調用onCreate(andorid.os.Bundle)到一個最終的黨法調用onDestroy().一個activity將在onCreate()方法中簡歷所有的全局狀態,且釋放所有的持有資源在OnDestory()方法中。例如,如果有一個線程在后在運行用來下載數據從網上,他可能創建縣城在onCreate()方法中且在onDestory()停止線程。
activity的可視的生命周期在方法onStart()開始,直到響應了方法onStop()。在這期間用戶可能看到activity在屏幕上,進過他可能不在最前面且和用不能戶進行交互。在這兩個方法之間,你的主要字眼需要展示activity給用戶。例如,你可以等級曠代接收在onStart()方法中來監視改變,從而影響你的UI且在onStop()方法中注銷當用戶不看你的展示的時候。onStart和onStop方法可以多次進行調用,當activity對用戶可視或者隱藏的時候。
整個activity的生命周期通過下面的Activity方法定義。所有這些方法你可能重寫當你的activity改變狀態的時候做一些事情。所有的activityes將實現onCreate(andoid.os.Bundle)方法來初始化,很多其他的也實現onPause()方法來確認對數據的改變,此外準備在用戶交互的時候停止。你應該常調用你的弗雷到你實現下列的方法的時候。
public class Activity extends ApplicationContext {
protected void onCreate(Bundle savedInstanceState);
protected void onStart();
protected void onRestart();
protected void onResume();
protected void onPause();
protected void onStop();
protected void onDestroy();
}
一個通用的貫穿整個activity生命周期的方法調用如下:
MethodDescriptionKillable?Next
onCreate()Called when the activity is first created. This is where you should do all of your normal static set up: create views, bind data to lists, etc. This method also provides you with a Bundle containing the activity's previously frozen state, if there was one.
Always followed byonStart().NoonStart()
onRestart()Called after your activity has been stopped, prior to it being started again.
Always followed byonStart()NoonStart()
onStart()Called when the activity is becoming visible to the user.
Followed byonResume()if the activity comes to the foreground, oronStop()if it becomes hidden.NoonResume()oronStop()
onResume()Called when the activity will start interacting with the user. At this point your activity is at the top of the activity stack, with user input going to it.
Always followed byonPause().NoonPause()
onPause()Called when the system is about to start resuming a previous activity. This is typically used to commit unsaved changes to persistent data, stop animations and other things that may be consuming CPU, etc. Implementations of this method must be very quick because the next activity will not be resumed until this method returns.
Followed by eitheronResume()if the activity returns back to the front, oronStop()if it becomes invisible to the user.YesonResume()or
onStop()
onStop()Called when the activity is no longer visible to the user, because another activity has been resumed and is covering this one. This may happen either because a new activity is being started, an existing one is being brought in front of this one, or this one is being destroyed.
Followed by eitheronRestart()if this activity is coming back to interact with the user, oronDestroy()if this activity is going away.YesonRestart()or
onDestroy()
onDestroy()The final call you receive before your activity is destroyed. This can happen either because the activity is finishing (someone calledfinish()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 theisFinishing()method.
記錄下上表中的“Killable”列,對于這些方法標記為能殺死,之后方法返回處理,通過掌握住activity可能被系統殺死在任何時候,在熱河一行代碼在執行的時候。因為這個原因,你應該使用onPsuse()方法來寫任何持久數據來存儲。此外,方法onSaveInstanceState(Bundle)被調用在放置activity在后臺轉臺之前,允許你保存任何動態視力狀態在你的acti到給定的Bundle中,之后再onCreate(android.os.Bundle)中接收,如果activity需要重新創建。看Process Lifecycle部分的更過信息關于如何將線程綁定到activity的集合。記錄下,在onPause()方法中存儲持久化數據而不再onSaveInstanceState()方法重要的原因是因為之后他不是生命周期回調的一部分,因此不會在每種情況下調用來描述他的文檔。
對于這些方法因為要被殺死,所以沒有標記,activity線程不會系統殺死在方法被調用且在其返回值后繼續使用。因此,一個activity處于可以被殺死的狀態,例如在onPause()方法之后再onResume()方法之前。
六、Configuration Changes
如果設備的配置發生了改變,那么用戶用來交互的界面需要更新來匹配數據。因為Activity是主要的用戶交互機制,他包含了特定的處理和數據改變。
除非你指定,一個配置改變(例如屏幕的方向,輸入設備等)將致使你當前的activity被銷毀,通過通常的activity生命周期調用onPause(),onStop(),和onDestroy()方法。如果activity被放置到了最前端或者對用戶可視,一旦|onDestroy()在實例中被調用,然后一個新的activity實例將被創建,而不去管saveInstanceState之前由onSaveInstanceState(android.os.Bundle)產生的實例。
在一些特定的例子中你可能想要通過旁路重啟你的activity,依據一個或者多個類型的配置改變。這個可以通過手動配置android:configChanges屬性實現。就如你說的對于任何類型的配置文件的改變你都要在哪里處理,你將接收到調用你當前activity的onConfigurationChanged(andoird.content.res.Configuration)方法而不是重新啟動。如果配置文件改變中包含了任何你不能處理的,然而,activity將重新啟動且onConfigrrationChanged()方法被調用。
6.1Starting Activities and Getting Results
方法startActivity()被用來啟動一個新的activity,且會將他放到activity棧的最頂部。這會導致一個爭論,一個Intent,描述activity的處理。
有時候當activity結束的時候你想要得到一個返回結果。例如,你可以啟動一個activity,當你從一個通訊錄列表中選擇一個用戶,當他結束的時候,將選擇的用戶返回。做這些,你調用startActivityForResult(Intent,int)使用第二個整形參數作為方法的區別。結果將返回通過onActivityResult(int,int,android.content.Intent)方法。
當activity存在,他可以調用setResult(int)方法來返回數據到父**。他必須唱提供一個返回的代碼,作為標準的結果RESULT_CANCELED,RESULT_OK或者任何通用值在啟動RESULT_FIRST_USER。此外,他可以選擇返回一個Intent包含任何你想要附加的數據。所有這些信息都可以出現在父Activity.onActivityResult(),以及它原來提供的整數標識符。
如果一個子activity因某個原因 失敗了,父activity將接收到結果代碼RESULT_CANCELED
public class MyActivity extends Activity {
...
static final int PICK_CONTACT_REQUEST = 0;
protected boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
// When the user center presses, let them pick a contact.
startActivityForResult(
new Intent(Intent.ACTION_PICK,
new Uri("content://contacts")),
PICK_CONTACT_REQUEST);
return true;
}
return false;
}
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == PICK_CONTACT_REQUEST) {
if (resultCode == RESULT_OK) {
// A contact was picked.? Here we will just display it
// to the user.
startActivity(new Intent(Intent.ACTION_VIEW, data));
}
}
}
}
6.2Saving Persistent State
通常有兩種持久化數據狀態需要處理,一種分享文檔數據(典型的存儲在SQLITE的數據,使用content provider)和內在的狀態例如用戶偏好。
對于內容提供者的數據,我們建議activity使用"edit in place"用戶模型。那就是,任何編輯,用戶使用高效的即可的而不需要二外的消息步驟。支持這個模型的通常是下面兩個原則的簡化;
當創建一個新的文件,同時創建他的支持數據庫條目或者文件。例如,如果用戶選擇寫一個新的郵件,在輸入數據的同時為郵件創建的條目,因此如果他們在此之后進入到任何其他的activity,這個郵件將出現到清單中。
當一個activity的onPause()方法被調用,他將確認返回內容提供者或者任何用戶創建的文件。這保證這些改變將被其他相關的,運行的activity看到。你可能想要提交你的數據甚至在你的activity的生命周期的一些關鍵時刻;例如在開始一個新的activity之前,在結束你自己的activity之前,當用戶在不同的輸入區域之間轉換等場景。
這個模型的設計是為了防止數據丟失當用戶是本地的在激活和允許系統安全的殺死一個activity在任何他被暫停的時刻。注意這個應用,用戶從你的activity中點擊返回不是意味著取消,他代表了離開activity且當前內容保存。在activity中取消編輯必須提供一些其他的機制,例如一個明確的“rever”或者“undo”選項。
看content package 能看到更多的信息。這個是不同的activity之間調用和傳播數據的關鍵地方。
Activity類也提供了API為管理內部的與activity關聯的持久狀態。這個可以使用,例如,在日歷中基礎用戶的初始化偏好或者用戶在網絡瀏覽器中的默認主頁。
Activity持久狀態使用方法getPreferences(int)來管理,允許你索引和修改一些列名稱/值對與activity關聯的。為了使用那些分享到多個應用組件的偏好,你可以使用下面的Context.getSharedPreferences()方法去索引偏好的對象存儲在一個指定的名稱下。(記住,分享設置數據跨越應用時不可能的,對于跨越你需要一個內容提供者)
下面是一個日歷摘錄activity用來存儲用戶的偏好視圖模型在持久化設置中。
public class CalendarActivity extends Activity {
...
static final int DAY_VIEW_MODE = 0;
static final int WEEK_VIEW_MODE = 1;
private SharedPreferences mPrefs;
private int mCurViewMode;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferences mPrefs = getSharedPreferences();
mCurViewMode = mPrefs.getInt("view_mode" DAY_VIEW_MODE);
}
protected void onPause() {
super.onPause();
SharedPreferences.Editor ed = mPrefs.edit();
ed.putInt("view_mode", mCurViewMode);
ed.commit();
}
}
7、Permissions
開始一個特定的Activity的能力可以強制執行,當他在manifest的<activity> 中聲明了tag。通過該動作,其他的應用需要聲明響應的<uses-permission>元素在他們自己的manifest中來允許啟動activity。
查看Security and Permissions文檔來獲取關于permission和security更多的信息。
8、Process Lifecycle
安卓系統嘗試盡可能長時間的保持應用處理能力,但是最后需要刪除舊的進程當內存低的時候。正如在Activity Lifecycle中描述的那樣,關于決定哪個進程被移除根據的是當前用戶交互的狀態信息。通常,根據activity的運行一個進程有四個狀態,依據重要性列表如下。系統將殺死相對不重要的進程,在殺死重要的進程之前。
1、最前面的activity(屏幕最上面的activity,用戶當前會交互)被認為是最重要的。這個進程被殺死的順序排在最后,如果他使用了很多的內存。通常此時設備已經達到了警告狀態,因此需要為了保持用戶界面響應。
2、一個可視的activity(activity能被用戶可視,但是不在最前面,例如在最前面后面的對話框)被人沒的非常重要的,且除非為了保證最前面的activity運行否則不會被殺死。
3、一個后臺運行的activity(不可見的activity,和已經暫停的)不會是決定性的,因此系統可能安全的殺死進程來釋放內存給其他的可視進程。如果這個進程需要被殺死,當用戶消極返回到activity(使得在屏幕上再次可視),他的onCreate()方法將被調用伴隨著saveInstanceState 已經預先應用到onSaveInstanceState(),因此他可以重新啟動自身在用戶上次使用的相同的狀態。
4、一個空的進程沒有被任何activity引用或者其他應用組件(例如service或者BroadcastTeceiver類)。當內存變低那些會被系統很快的殺死。對于這個原因,任何在activity之外的后臺運算必須在activity中處理。BroadcastReceiver 或者 service 來保證系統知道他需要保持進程。
有時候一個activity可能需要一個長時間的運行運算,獨立存在于activity的生命周期。一個例子就是相機應用允許你上傳照片到一個網站。上傳需要花費很長的時間,且應用允許用戶離開應用來處理。為了完成這個,你的activity應該啟動一個service用來上傳。這允許系統排序權限(認為他比其他不可視的應用要重要)給你的進程在上傳的期間,獨立于原生activity的暫停,停止和結束。
字段摘要
static intDEFAULT_KEYS_DIALER
Use withsetDefaultKeyMode(int)to launch the dialer during default key handling.
static intDEFAULT_KEYS_DISABLE
Use withsetDefaultKeyMode(int)to turn off default handling of keys.
static intDEFAULT_KEYS_SEARCH_GLOBAL
Use withsetDefaultKeyMode(int)to specify that unhandled keystrokes will start a global search (typically web search, but some platforms may define alternate methods for global search) Seeandroid.app.SearchManagerfor more details.
static intDEFAULT_KEYS_SEARCH_LOCAL
Use withsetDefaultKeyMode(int)to specify that unhandled keystrokes will start an application-defined search.
static intDEFAULT_KEYS_SHORTCUT
Use withsetDefaultKeyMode(int)to execute a menu shortcut in default key handling.
static intRESULT_CANCELED
Standard activity result: operation canceled.
static intRESULT_FIRST_USER
Start of user-defined activity results.
static intRESULT_OK
Standard activity result: operation succeeded.
方法摘要
voidaddContentView(Viewview,ViewGroup.LayoutParamsparams)
Add an additional content view to the activity.
voidcloseContextMenu()
Programmatically closes the most recently opened context menu, if showing.
voidcloseOptionsMenu()
Progammatically closes the options menu.
PendingIntentcreatePendingResult(int requestCode,Intentdata, int flags)
Create a new PendingIntent object which you can hand to others for them to use to send result data back to youronActivityResult(int,
int, android.content.Intent)callback.
voiddismissDialog(int id)
Dismiss a dialog that was previously shown viashowDialog(int).
booleandispatchKeyEvent(KeyEventevent)
Called to process key events.
booleandispatchTouchEvent(MotionEventev)
Called to process touch screen events.
booleandispatchTrackballEvent(MotionEventev)
Called to process trackball events.
ViewfindViewById(int id)
Finds a view that was identified by the id attribute from the XML that was processed inonCreate(android.os.Bundle).
voidfinish()
Call this when your activity is done and should be closed.
voidfinishActivity(int requestCode)
Force finish another activity that you had previously started withstartActivityForResult(android.content.Intent,
int).
voidfinishActivityFromChild(Activitychild, int requestCode)
This is called when a child activity of this one calls its finishActivity().
voidfinishFromChild(Activitychild)
This is called when a child activity of this one calls itsfinish()method.
Return the application that owns this activity.
ComponentNamegetCallingActivity()
Return the name of the activity that invoked this activity.
Return the name of the package that invoked this activity.
intgetChangingConfigurations()
If this activity is being destroyed because it can not handle a configuration parameter being changed (and thus itsonConfigurationChanged(Configuration)method isnotbeing called), then you can use this method to discover the set of changes that have occurred while in the process of being destroyed.
ComponentNamegetComponentName()
Returns complete component name of this activity.
CallsWindow.getCurrentFocus()on the Window of this Activity to return the currently focused view.
static longgetInstanceCount()
Return the intent that started this activity.
ObjectgetLastNonConfigurationInstance()
Retrieve the non-configuration instance data that was previously returned byonRetainNonConfigurationInstance().
LayoutInflatergetLayoutInflater()
Convenience for callingWindow.getLayoutInflater().
Returns class name for this activity with the package prefix removed.
Returns aMenuInflaterwith this context.
Return the parent activity if this view is an embedded child.
SharedPreferencesgetPreferences(int mode)
Retrieve aSharedPreferencesobject for accessing preferences that are private to this activity.
Return the current requested orientation of the activity.
ObjectgetSystemService(Stringname)
Return the handle to a system-level service by name.
intgetTaskId()
Return the identifier of the task this activity is in.
intgetTitleColor()
Gets the suggested audio stream whose volume should be changed by the harwdare volume controls.
intgetWallpaperDesiredMinimumHeight()
Returns the desired minimum height for the wallpaper.
intgetWallpaperDesiredMinimumWidth()
Returns the desired minimum width for the wallpaper.
Retrieve the currentWindowfor the activity.
WindowManagergetWindowManager()
Retrieve the window manager for showing custom windows.
booleanhasWindowFocus()
Returns true if this activity'smainwindow currently has window focus.
booleanisChild()
Is this activity embedded inside of another activity?
booleanisFinishing()
Check to see whether this activity is in the process of finishing, either because you calledfinish()on it or someone else has requested that it finished.
booleanisTaskRoot()
Return whether this activity is the root of a task.
voidmanagedCommitUpdates(Cursorc)
已過時。
CursormanagedQuery(Uriuri,String[] projection,Stringselection,StringsortOrder)
Wrapper aroundContentResolver.query(android.net.Uri
, String[], String, String[], String)that gives the resultingCursorto callstartManagingCursor(android.database.Cursor)so that the activity will manage its lifecycle for you.
CursormanagedQuery(Uriuri,String[] projection,Stringselection,String[] selectionArgs,StringsortOrder)
Wrapper aroundContentResolver.query(android.net.Uri
, String[], String, String[], String)that gives the resultingCursorto callstartManagingCursor(android.database.Cursor)so that the activity will manage its lifecycle for you.
booleanmoveTaskToBack(boolean nonRoot)
Move the task containing this activity to the back of the activity stack.
voidonConfigurationChanged(ConfigurationnewConfig)
Called by the system when the device configuration changes while your activity is running.
voidonContentChanged()
This hook is called whenever the content view of the screen changes (due to a call toWindow.setContentVieworWindow.addContentView).
booleanonContextItemSelected(MenuItemitem)
This hook is called whenever an item in a context menu is selected.
voidonContextMenuClosed(Menumenu)
This hook is called whenever the context menu is being closed (either by the user canceling the menu with the back/menu button, or when an item is selected).
voidonCreateContextMenu(ContextMenumenu,Viewv,ContextMenu.ContextMenuInfomenuInfo)
Called when a context menu for theviewis about to be shown.
CharSequenceonCreateDescription()
Generate a new description for this activity.
booleanonCreateOptionsMenu(Menumenu)
Initialize the contents of the Activity's standard options menu.
booleanonCreatePanelMenu(int featureId,Menumenu)
Default implementation ofWindow.Callback.onCreatePanelMenu(int,
android.view.Menu)for activities.
ViewonCreatePanelView(int featureId)
Default implementation ofWindow.Callback.onCreatePanelView(int)for activities.
booleanonCreateThumbnail(BitmapoutBitmap,Canvascanvas)
Generate a new thumbnail for this activity.
ViewonCreateView(Stringname,Contextcontext,AttributeSetattrs)
Stub implementation ofLayoutInflater.Factory.onCreateView(java.lang.String,
android.content.Context, android.util.AttributeSet)used when inflating with the LayoutInflater returned bygetSystemService(java.lang.String).
booleanonKeyDown(int keyCode,KeyEventevent)
Called when a key was pressed down and not handled by any of the views inside of the activity.
booleanonKeyMultiple(int keyCode, int repeatCount,KeyEventevent)
Default implementation ofKeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle the event).
booleanonKeyUp(int keyCode,KeyEventevent)
Called when a key was released and not handled by any of the views inside of the activity.
voidonLowMemory()
This is called when the overall system is running low on memory, and would like actively running process to try to tighten their belt.
booleanonMenuItemSelected(int featureId,MenuItemitem)
Default implementation ofWindow.Callback.onMenuItemSelected(int,
android.view.MenuItem)for activities.
booleanonMenuOpened(int featureId,Menumenu)
Called when a panel's menu is opened by the user.
booleanonOptionsItemSelected(MenuItemitem)
This hook is called whenever an item in your options menu is selected.
voidonOptionsMenuClosed(Menumenu)
This hook is called whenever the options menu is being closed (either by the user canceling the menu with the back/menu button, or when an item is selected).
voidonPanelClosed(int featureId,Menumenu)
Default implementation ofWindow.Callback.onPanelClosed(int,
Menu)for activities.
booleanonPrepareOptionsMenu(Menumenu)
Prepare the Screen's standard options menu to be displayed.
booleanonPreparePanel(int featureId,Viewview,Menumenu)
Default implementation ofWindow.Callback.onPreparePanel(int,
android.view.View, android.view.Menu)for activities.
ObjectonRetainNonConfigurationInstance()
Called by the system, as part of destroying an activity due to a configuration change, when it is known that a new instance will immediately be created for the new configuration.
booleanonSearchRequested()
This hook is called when the user signals the desire to start a search.
booleanonTouchEvent(MotionEventevent)
Called when a touch screen event was not handled by any of the views under it.
booleanonTrackballEvent(MotionEventevent)
Called when the trackball was moved and not handled by any of the views inside of the activity.
voidonUserInteraction()
Called whenever a key, touch, or trackball event is dispatched to the activity.
voidonWindowAttributesChanged(WindowManager.LayoutParamsparams)
This is called whenever the current window attributes change.
voidonWindowFocusChanged(boolean hasFocus)
Called when the currentWindowof the activity gains or loses focus.
voidopenContextMenu(Viewview)
Programmatically opens the context menu for a particularview.
voidopenOptionsMenu()
Programmatically opens the options menu.
voidregisterForContextMenu(Viewview)
Registers a context menu to be shown for the given view (multiple views can show the context menu).
voidremoveDialog(int id)
Removes any internal references to a dialog managed by this Activity.
booleanrequestWindowFeature(int featureId)
Enable extended window features.
voidrunOnUiThread(Runnableaction)
Runs the specified action on the UI thread.
voidsetContentView(int layoutResID)
Set the activity content from a layout resource.
voidsetContentView(Viewview)
Set the activity content to an explicit view.
voidsetContentView(Viewview,ViewGroup.LayoutParamsparams)
Set the activity content to an explicit view.
voidsetDefaultKeyMode(int mode)
Select the default key handling for this activity.
voidsetFeatureDrawable(int featureId,Drawabledrawable)
Convenience for callingWindow.setFeatureDrawable(int,
Drawable).
voidsetFeatureDrawableAlpha(int featureId, int alpha)
Convenience for callingWindow.setFeatureDrawableAlpha(int,
int).
voidsetFeatureDrawableResource(int featureId, int resId)
Convenience for callingWindow.setFeatureDrawableResource(int,
int).
voidsetFeatureDrawableUri(int featureId,Uriuri)
Convenience for callingWindow.setFeatureDrawableUri(int,
android.net.Uri).
voidsetIntent(IntentnewIntent)
Change the intent returned bygetIntent().
voidsetPersistent(boolean isPersistent)
Control whether this activity is required to be persistent.
voidsetProgress(int progress)
Sets the progress for the progress bars in the title.
voidsetProgressBarIndeterminate(boolean indeterminate)
Sets whether the horizontal progress bar in the title should be indeterminate (the circular is always indeterminate).
voidsetProgressBarIndeterminateVisibility(boolean visible)
Sets the visibility of the indeterminate progress bar in the title.
voidsetProgressBarVisibility(boolean visible)
Sets the visibility of the progress bar in the title.
voidsetRequestedOrientation(int requestedOrientation)
Change the desired orientation of this activity.
voidsetResult(int resultCode)
Call this to set the result that your activity will return to its caller.
voidsetResult(int resultCode,Intentdata)
Call this to set the result that your activity will return to its caller.
voidsetSecondaryProgress(int secondaryProgress)
Sets the secondary progress for the progress bar in the title.
voidsetTitle(CharSequencetitle)
Change the title associated with this activity.
voidsetTitle(int titleId)
Change the title associated with this activity.
voidsetTitleColor(int textColor)
voidsetVisible(boolean visible)
Control whether this activity's main window is visible.
voidsetVolumeControlStream(int streamType)
Suggests an audio stream whose volume should be changed by the hardware volume controls.
voidshowDialog(int id)
Show a dialog managed by this activity.
voidstartActivity(Intentintent)
Launch a new activity.
voidstartActivityForResult(Intentintent, int requestCode)
Launch an activity for which you would like a result when it finished.
voidstartActivityFromChild(Activitychild,Intentintent, int requestCode)
This is called when a child activity of this one calls itsstartActivity(android.content.Intent)orstartActivityForResult(android.content.Intent,
int)method.
booleanstartActivityIfNeeded(Intentintent, int requestCode)
A special variation to launch an activity only if a new activity instance is needed to handle the given Intent.
voidstartManagingCursor(Cursorc)
This method allows the activity to take care of managing the givenCursor's lifecycle for you based on the activity's lifecycle.
booleanstartNextMatchingActivity(Intentintent)
Special version of starting an activity, for use when you are replacing other activity components.
voidstartSearch(StringinitialQuery, boolean selectInitialQuery,BundleappSearchData, boolean globalSearch)
This hook is called to launch the search UI.
voidstopManagingCursor(Cursorc)
Given a Cursor that was previously given tostartManagingCursor(android.database.Cursor), stop the activity's management of that cursor.
voidtakeKeyEvents(boolean get)
Request that key events come to this activity.
voidunregisterForContextMenu(Viewview)
Prevents a context menu to be shown for the given view.