core/java/android/content/Intent.java - platform/frameworks/base
文章推薦指數: 80 %
* defined in the Intent class, but applications can also define their own. * These strings use java style scoping, to ensure they are unique -- for. * example, ... android/platform/frameworks/base/135936072b24b090fb63940aea41b408d855a4f3/./core/java/android/content/Intent.javablob:24c2461c67870e1bb5ee9404b6c44742654a0977[file][log][blame]/**Copyright(C)2006TheAndroidOpenSourceProject**LicensedundertheApacheLicense,Version2.0(the"License");*youmaynotusethisfileexceptincompliancewiththeLicense.*YoumayobtainacopyoftheLicenseat**http://www.apache.org/licenses/LICENSE-2.0**Unlessrequiredbyapplicablelaworagreedtoinwriting,software*distributedundertheLicenseisdistributedonan"ASIS"BASIS,*WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.*SeetheLicenseforthespecificlanguagegoverningpermissionsand*limitationsundertheLicense.*/packageandroid.content;importorg.xmlpull.v1.XmlPullParser;importorg.xmlpull.v1.XmlPullParserException;importandroid.annotation.SdkConstant;importandroid.annotation.SdkConstant.SdkConstantType;importandroid.content.pm.ActivityInfo;importandroid.content.pm.PackageManager;importandroid.content.pm.ResolveInfo;importandroid.content.res.Resources;importandroid.content.res.TypedArray;importandroid.graphics.Rect;importandroid.net.Uri;importandroid.os.Bundle;importandroid.os.IBinder;importandroid.os.Parcel;importandroid.os.Parcelable;importandroid.util.AttributeSet;importandroid.util.Log;importcom.android.internal.util.XmlUtils;importjava.io.IOException;importjava.io.Serializable;importjava.net.URISyntaxException;importjava.util.ArrayList;importjava.util.HashSet;importjava.util.Iterator;importjava.util.Locale;importjava.util.Set;/***Anintentisanabstractdescriptionofanoperationtobeperformed.It*canbeusedwith{@linkContext#startActivity(Intent)startActivity}to*launchan{@linkandroid.app.Activity},*{@linkandroid.content.Context#sendBroadcast(Intent)broadcastIntent}to*sendittoanyinterested{@linkBroadcastReceiverBroadcastReceiver}components,*and{@linkandroid.content.Context#startService}or*{@linkandroid.content.Context#bindService}tocommunicatewitha*background{@linkandroid.app.Service}.**
AnIntentprovidesafacilityforperforminglateruntimebindingbetweenthecodein*differentapplications.Itsmostsignificantuseisinthelaunchingofactivities,whereit*canbethoughtofasthegluebetweenactivities.Itisbasicallyapassivedatastructure*holdinganabstractdescriptionofanactiontobeperformed.
**DeveloperGuides
*Forinformationabouthowtocreateandresolveintents,readthe*
IntentStructure
*Theprimarypiecesofinformationinanintentare:
**- *
-
action--Thegeneralactiontobeperformed,suchas*{@link#ACTION_VIEW},{@link#ACTION_EDIT},{@link#ACTION_MAIN},*etc.
* * -
data--Thedatatooperateon,suchasapersonrecord*inthecontactsdatabase,expressedasa{@linkandroid.net.Uri}.
* *
Someexamplesofaction/datapairsare:
**- *
-
{@link#ACTION_VIEW}content://contacts/people/1--Display*informationaboutthepersonwhoseidentifieris"1".
* * -
{@link#ACTION_DIAL}content://contacts/people/1--Display*thephonedialerwiththepersonfilledin.
* * -
{@link#ACTION_VIEW}tel:123--Display*thephonedialerwiththegivennumberfilledin.Notehowthe*VIEWactiondoeswhatwhatisconsideredthemostreasonablethingfor*aparticularURI.
* * -
{@link#ACTION_DIAL}tel:123--Display*thephonedialerwiththegivennumberfilledin.
* * -
{@link#ACTION_EDIT}content://contacts/people/1--Edit*informationaboutthepersonwhoseidentifieris"1".
* * -
{@link#ACTION_VIEW}content://contacts/people/--Display*alistofpeople,whichtheusercanbrowsethrough.Thisexampleisa*typicaltop-levelentryintotheContactsapplication,showingyouthe*listofpeople.Selectingaparticularpersontoviewwouldresultina*newintent{{@link#ACTION_VIEW}content://contacts/N}*beingusedtostartanactivitytodisplaythatperson.
* *
Inadditiontotheseprimaryattributes,thereareanumberofsecondary*attributesthatyoucanalsoincludewithanintent:
**- *
-
category--Givesadditionalinformationabouttheaction*toexecute.Forexample,{@link#CATEGORY_LAUNCHER}meansitshould*appearintheLauncherasatop-levelapplication,while*{@link#CATEGORY_ALTERNATIVE}meansitshouldbeincludedinalist*ofalternativeactionstheusercanperformonapieceofdata.
* -
type--Specifiesanexplicittype(aMIMEtype)ofthe*intentdata.Normallythetypeisinferredfromthedataitself.*Bysettingthisattribute,youdisablethatevaluationandforce*anexplicittype.
* -
component--Specifiesanexplicitnameofacomponent*classtousefortheintent.Normallythisisdeterminedbylooking*attheotherinformationintheintent(theaction,data/type,and*categories)andmatchingthatwithacomponentthatcanhandleit.*Ifthisattributeissetthennoneoftheevaluationisperformed,*andthiscomponentisusedexactlyasis.Byspecifyingthisattribute,*alloftheotherIntentattributesbecomeoptional.
* -
extras--Thisisa{@linkBundle}ofanyadditionalinformation.*Thiscanbeusedtoprovideextendedinformationtothecomponent.*Forexample,ifwehaveaactiontosendane-mailmessage,wecould*alsoincludeextrapiecesofdataheretosupplyasubject,body,*etc.
*
Herearesomeexamplesofotheroperationsyoucanspecifyasintents*usingtheseadditionalparameters:
**- *
-
{@link#ACTION_MAIN}withcategory{@link#CATEGORY_HOME}--*Launchthehomescreen.
* * -
{@link#ACTION_GET_CONTENT}withMIMEtype*{@linkandroid.provider.Contacts.Phones#CONTENT_URI*vnd.android.cursor.item/phone}*--Displaythelistofpeople'sphonenumbers,allowingtheuserto*browsethroughthemandpickoneandreturnittotheparentactivity.
* * -
{@link#ACTION_GET_CONTENT}withMIMEtype**{@literal/}*andcategory{@link#CATEGORY_OPENABLE}*--Displayallpickersfordatathatcanbeopenedwith*{@linkContentResolver#openInputStream(Uri)ContentResolver.openInputStream()},*allowingtheusertopickoneofthemandthensomedatainsideofit*andreturningtheresultingURItothecaller.Thiscanbeused,*forexample,inane-mailapplicationtoallowtheusertopicksome*datatoincludeasanattachment.
* *
ThereareavarietyofstandardIntentactionandcategoryconstants*definedintheIntentclass,butapplicationscanalsodefinetheirown.*Thesestringsusejavastylescoping,toensuretheyareunique--for*example,thestandard{@link#ACTION_VIEW}iscalled*"android.intent.action.VIEW".
**Puttogether,thesetofactions,datatypes,categories,andextradata*definesalanguageforthesystemallowingfortheexpressionofphrases*suchas"calljohnsmith'scell".Asapplicationsareaddedtothesystem,*theycanextendthislanguagebyaddingnewactions,types,andcategories,or*theycanmodifythebehaviorofexistingphrasesbysupplyingtheirown*activitiesthathandlethem.
**IntentResolution
**Therearetwoprimaryformsofintentsyouwilluse.**
- *
ExplicitIntentshavespecifiedacomponent(via*{@link#setComponent}or{@link#setClass}),whichprovidestheexact*classtoberun.Oftenthesewillnotincludeanyotherinformation,*simplybeingawayforanapplicationtolaunchvariousinternal*activitiesithasastheuserinteractswiththeapplication.**
ImplicitIntentshavenotspecifiedacomponent;*instead,theymustincludeenoughinformationforthesystemto*determinewhichoftheavailablecomponentsisbesttorunforthat*intent.*
Whenusingimplicitintents,givensuchanarbitraryintentweneedto*knowwhattodowithit.ThisishandledbytheprocessofIntent*resolution,whichmapsanIntenttoan{@linkandroid.app.Activity},*{@linkBroadcastReceiver},or{@linkandroid.app.Service}(orsometimestwoor*moreactivities/receivers)thatcanhandleit.
**Theintentresolutionmechanismbasicallyrevolvesaroundmatchingan*Intentagainstallofthe<intent-filter>descriptionsinthe*installedapplicationpackages.(Plus,inthecaseofbroadcasts,any{@linkBroadcastReceiver}*objectsexplicitlyregisteredwith{@linkContext#registerReceiver}.)More*detailsonthiscanbefoundinthedocumentationonthe{@link*IntentFilter}class.
**TherearethreepiecesofinformationintheIntentthatareusedfor*resolution:theaction,type,andcategory.Usingthisinformation,aquery*isdoneonthe{@linkPackageManager}foracomponentthatcanhandlethe*intent.Theappropriatecomponentisdeterminedbasedontheintent*informationsuppliedintheAndroidManifest.xml
fileas*follows:
- *
-
Theaction,ifgiven,mustbelistedbythecomponentas*oneithandles.
* -
ThetypeisretrievedfromtheIntent'sdata,ifnot*alreadysuppliedintheIntent.Liketheaction,ifatypeis*includedintheintent(eitherexplicitlyorimplicitlyinits*data),thenthismustbelistedbythecomponentasoneithandles.
* - Fordatathatisnota
content:
URIandwherenoexplicit*typeisincludedintheIntent,insteadtheschemeofthe*intentdata(suchashttp:
ormailto:
)is*considered.Againliketheaction,ifwearematchingaschemeit*mustbelistedbythecomponentasoneitcanhandle.* -
Thecategories,ifsupplied,mustallbelisted*bytheactivityascategoriesithandles.Thatis,ifyouinclude*thecategories{@link#CATEGORY_LAUNCHER}and*{@link#CATEGORY_ALTERNATIVE},thenyouwillonlyresolvetocomponents*withanintentthatlistsbothofthosecategories.*Activitieswillveryoftenneedtosupportthe*{@link#CATEGORY_DEFAULT}sothattheycanbefoundby*{@linkContext#startActivityContext.startActivity()}.
*
Forexample,considertheNotePadsampleapplicationthat*allowsusertobrowsethroughalistofnotesdataandviewdetailsabout*individualitems.Textinitalicsindicateplaceswereyouwouldreplacea*namewithonespecifictoyourownpackage.
**<manifestxmlns:android="http://schemas.android.com/apk/res/android"*package="com.android.notepad">*<applicationandroid:icon="@drawable/app_notes"*android:label="@string/app_name">**<providerclass=".NotePadProvider"*android:authorities="com.google.provider.NotePad"/>**<activityclass=".NotesList"android:label="@string/title_notes_list">*<intent-filter>*<actionandroid:name="android.intent.action.MAIN"/>*<categoryandroid:name="android.intent.category.LAUNCHER"/>*</intent-filter>*<intent-filter>*<actionandroid:name="android.intent.action.VIEW"/>*<actionandroid:name="android.intent.action.EDIT"/>*<actionandroid:name="android.intent.action.PICK"/>*<categoryandroid:name="android.intent.category.DEFAULT"/>*<dataandroid:mimeType="vnd.android.cursor.dir/vnd.google.note"/>*</intent-filter>*<intent-filter>*<actionandroid:name="android.intent.action.GET_CONTENT"/>*<categoryandroid:name="android.intent.category.DEFAULT"/>*<dataandroid:mimeType="vnd.android.cursor.item/vnd.google.note"/>*</intent-filter>*</activity>**<activityclass=".NoteEditor"android:label="@string/title_note">*<intent-filterandroid:label="@string/resolve_edit">*<actionandroid:name="android.intent.action.VIEW"/>*<actionandroid:name="android.intent.action.EDIT"/>*<categoryandroid:name="android.intent.category.DEFAULT"/>*<dataandroid:mimeType="vnd.android.cursor.item/vnd.google.note"/>*</intent-filter>**<intent-filter>*<actionandroid:name="android.intent.action.INSERT"/>*<categoryandroid:name="android.intent.category.DEFAULT"/>*<dataandroid:mimeType="vnd.android.cursor.dir/vnd.google.note"/>*</intent-filter>**</activity>**<activityclass=".TitleEditor"android:label="@string/title_edit_title"*android:theme="@android:style/Theme.Dialog">*<intent-filterandroid:label="@string/resolve_title">*<actionandroid:name="com.android.notepad.action.EDIT_TITLE"/>*<categoryandroid:name="android.intent.category.DEFAULT"/>*<categoryandroid:name="android.intent.category.ALTERNATIVE"/>*<categoryandroid:name="android.intent.category.SELECTED_ALTERNATIVE"/>*<dataandroid:mimeType="vnd.android.cursor.item/vnd.google.note"/>*</intent-filter>*</activity>**</application>*</manifest>**
Thefirstactivity,*com.android.notepad.NotesList
,servesasourmain*entryintotheapp.Itcandothreethingsasdescribedbyitsthreeintent*templates:*
- *
-
*<intent-filter>*<actionandroid:name="{@link#ACTION_MAINandroid.intent.action.MAIN}"/>*<categoryandroid:name="{@link#CATEGORY_LAUNCHERandroid.intent.category.LAUNCHER}"/>*</intent-filter>
*Thisprovidesatop-levelentryintotheNotePadapplication:thestandard*MAINactionisamainentrypoint(notrequiringanyotherinformationin*theIntent),andtheLAUNCHERcategorysaysthatthisentrypointshouldbe*listedintheapplicationlauncher.
* -
*<intent-filter>*<actionandroid:name="{@link#ACTION_VIEWandroid.intent.action.VIEW}"/>*<actionandroid:name="{@link#ACTION_EDITandroid.intent.action.EDIT}"/>*<actionandroid:name="{@link#ACTION_PICKandroid.intent.action.PICK}"/>*<categoryandroid:name="{@link#CATEGORY_DEFAULTandroid.intent.category.DEFAULT}"/>*<datamimeType:name="vnd.android.cursor.dir/vnd.google.note"/>*</intent-filter>
*Thisdeclaresthethingsthattheactivitycandoonadirectoryof*notes.Thetypebeingsupportedisgivenwiththe<type>tag,where*
*vnd.android.cursor.dir/vnd.google.note
isaURIfromwhich*aCursorofzeroormoreitems(vnd.android.cursor.dir
)can*beretrievedwhichholdsournotepaddata(vnd.google.note
).*Theactivityallowstheusertovieworeditthedirectoryofdata(via*theVIEWandEDITactions),ortopickaparticularnoteandreturnit*tothecaller(viathePICKaction).NotealsotheDEFAULTcategory*suppliedhere:thisisrequiredforthe*{@linkContext#startActivityContext.startActivity}methodtoresolveyour*activitywhenitscomponentnameisnotexplicitlyspecified. -
*<intent-filter>*<actionandroid:name="{@link#ACTION_GET_CONTENTandroid.intent.action.GET_CONTENT}"/>*<categoryandroid:name="{@link#CATEGORY_DEFAULTandroid.intent.category.DEFAULT}"/>*<dataandroid:mimeType="vnd.android.cursor.item/vnd.google.note"/>*</intent-filter>
*Thisfilterdescribestheabilityreturntothecalleranoteselectedby*theuserwithoutneedingtoknowwhereitcamefrom.Thedatatype*
*vnd.android.cursor.item/vnd.google.note
isaURIfromwhich*aCursorofexactlyone(vnd.android.cursor.item
)itemcan*beretrievedwhichcontainsournotepaddata(vnd.google.note
).*TheGET_CONTENTactionissimilartothePICKaction,wheretheactivity*willreturntoitscallerapieceofdataselectedbytheuser.Here,*however,thecallerspecifiesthetypeofdatatheydesireinsteadof*thetypeofdatatheuserwillbepickingfrom.
Giventhesecapabilities,thefollowingintentswillresolvetothe*NotesListactivity:
**- *
-
{action=android.app.action.MAIN}matchesallofthe*activitiesthatcanbeusedastop-levelentrypointsintoan*application.
* -
{action=android.app.action.MAIN,*category=android.app.category.LAUNCHER}istheactualintent*usedbytheLaunchertopopulateitstop-levellist.
* -
{action=android.intent.action.VIEW*data=content://com.google.provider.NotePad/notes}*displaysalistofallthenotesunder*"content://com.google.provider.NotePad/notes",which*theusercanbrowsethroughandseethedetailson.
* -
{action=android.app.action.PICK*data=content://com.google.provider.NotePad/notes}*providesalistofthenotesunder*"content://com.google.provider.NotePad/notes",fromwhich*theusercanpickanotewhosedataURLisreturnedbacktothecaller.
* -
{action=android.app.action.GET_CONTENT*type=vnd.android.cursor.item/vnd.google.note}*issimilartothepickaction,butallowsthecallertospecifythe*kindofdatatheywantbacksothatthesystemcanfindtheappropriate*activitytopicksomethingofthatdatatype.
*
Thesecondactivity,*com.android.notepad.NoteEditor
,showstheuserasingle*noteentryandallowsthemtoeditit.Itcandotwothingsasdescribed*byitstwointenttemplates:*
- *
-
*<intent-filterandroid:label="@string/resolve_edit">*<actionandroid:name="{@link#ACTION_VIEWandroid.intent.action.VIEW}"/>*<actionandroid:name="{@link#ACTION_EDITandroid.intent.action.EDIT}"/>*<categoryandroid:name="{@link#CATEGORY_DEFAULTandroid.intent.category.DEFAULT}"/>*<dataandroid:mimeType="vnd.android.cursor.item/vnd.google.note"/>*</intent-filter>
*Thefirst,primary,purposeofthisactivityistolettheuserinteract*withasinglenote,asdecribedbytheMIMEtype*
*vnd.android.cursor.item/vnd.google.note
.Theactivitycan*eitherVIEWanoteorallowtheusertoEDITit.Againwesupportthe*DEFAULTcategorytoallowtheactivitytobelaunchedwithoutexplicitly*specifyingitscomponent. -
*<intent-filter>*<actionandroid:name="{@link#ACTION_INSERTandroid.intent.action.INSERT}"/>*<categoryandroid:name="{@link#CATEGORY_DEFAULTandroid.intent.category.DEFAULT}"/>*<dataandroid:mimeType="vnd.android.cursor.dir/vnd.google.note"/>*</intent-filter>
*Thesecondaryuseofthisactivityistoinsertanewnoteentryinto*anexistingdirectoryofnotes.Thisisusedwhentheusercreatesanew*note:theINSERTactionisexecutedonthedirectoryofnotes,causing*thisactivitytorunandhavetheusercreatethenewnotedatawhich*itthenaddstothecontentprovider.
*
Giventhesecapabilities,thefollowingintentswillresolvetothe*NoteEditoractivity:
**- *
-
{action=android.intent.action.VIEW*data=content://com.google.provider.NotePad/notes/{ID}}*showstheuserthecontentofnote{ID}.
* -
{action=android.app.action.EDIT*data=content://com.google.provider.NotePad/notes/{ID}}*allowstheusertoeditthecontentofnote{ID}.
* -
{action=android.app.action.INSERT*data=content://com.google.provider.NotePad/notes}*createsanew,emptynoteinthenoteslistat*"content://com.google.provider.NotePad/notes"*andallowstheusertoeditit.Iftheykeeptheirchanges,theURI*ofthenewlycreatednoteisreturnedtothecaller.
*
Thelastactivity,*com.android.notepad.TitleEditor
,allowstheuserto*editthetitleofanote.Thiscouldbeimplementedasaclassthatthe*applicationdirectlyinvokes(byexplicitlysettingitscomponentin*theIntent),buthereweshowawayyoucanpublishalternative*operationsonexistingdata:
*<intent-filterandroid:label="@string/resolve_title">*<actionandroid:name="com.android.notepad.action.EDIT_TITLE"/>*<categoryandroid:name="{@link#CATEGORY_DEFAULTandroid.intent.category.DEFAULT}"/>*<categoryandroid:name="{@link#CATEGORY_ALTERNATIVEandroid.intent.category.ALTERNATIVE}"/>*<categoryandroid:name="{@link#CATEGORY_SELECTED_ALTERNATIVEandroid.intent.category.SELECTED_ALTERNATIVE}"/>*<dataandroid:mimeType="vnd.android.cursor.item/vnd.google.note"/>*</intent-filter>**
Inthesingleintenttemplatehere,we*havecreatedourownprivateactioncalled*com.android.notepad.action.EDIT_TITLE
whichmeansto*editthetitleofanote.Itmustbeinvokedonaspecificnote*(datatypevnd.android.cursor.item/vnd.google.note
)liketheprevious*viewandeditactions,butheredisplaysandeditsthetitlecontained*inthenotedata.**
Inadditiontosupportingthedefaultcategoryasusual,ourtitleeditor*alsosupportstwootherstandardcategories:ALTERNATIVEand*SELECTED_ALTERNATIVE.Implementing*thesecategoriesallowsotherstofindthespecialactionitprovides*withoutdirectlyknowingaboutit,throughthe*{@linkandroid.content.pm.PackageManager#queryIntentActivityOptions}method,or*moreoftentobuilddynamicmenuitemswith*{@linkandroid.view.Menu#addIntentOptions}.Notethatintheintent*templateherewasalsosupplyanexplicitnameforthetemplate*(viaandroid:label="@string/resolve_title"
)tobettercontrol*whattheuserseeswhenpresentedwiththisactivityasanalternative*actiontothedatatheyareviewing.**
Giventhesecapabilities,thefollowingintentwillresolvetothe*TitleEditoractivity:
**- *
-
{action=com.android.notepad.action.EDIT_TITLE*data=content://com.google.provider.NotePad/notes/{ID}}*displaysandallowstheusertoeditthetitleassociated*withnote{ID}.
*
StandardActivityActions
**ThesearethecurrentstandardactionsthatIntentdefinesforlaunching*activities(usuallythrough{@linkContext#startActivity}.Themost*important,andbyfarmostfrequentlyused,are{@link#ACTION_MAIN}and*{@link#ACTION_EDIT}.**
- *
- {@link#ACTION_MAIN}*
- {@link#ACTION_VIEW}*
- {@link#ACTION_ATTACH_DATA}*
- {@link#ACTION_EDIT}*
- {@link#ACTION_PICK}*
- {@link#ACTION_CHOOSER}*
- {@link#ACTION_GET_CONTENT}*
- {@link#ACTION_DIAL}*
- {@link#ACTION_CALL}*
- {@link#ACTION_SEND}*
- {@link#ACTION_SENDTO}*
- {@link#ACTION_ANSWER}*
- {@link#ACTION_INSERT}*
- {@link#ACTION_DELETE}*
- {@link#ACTION_RUN}*
- {@link#ACTION_SYNC}*
- {@link#ACTION_PICK_ACTIVITY}*
- {@link#ACTION_SEARCH}*
- {@link#ACTION_WEB_SEARCH}*
- {@link#ACTION_FACTORY_TEST}*
StandardBroadcastActions
**ThesearethecurrentstandardactionsthatIntentdefinesforreceiving*broadcasts(usuallythrough{@linkContext#registerReceiver}ora*<receiver>taginamanifest).**
- *
- {@link#ACTION_TIME_TICK}*
- {@link#ACTION_TIME_CHANGED}*
- {@link#ACTION_TIMEZONE_CHANGED}*
- {@link#ACTION_BOOT_COMPLETED}*
- {@link#ACTION_PACKAGE_ADDED}*
- {@link#ACTION_PACKAGE_CHANGED}*
- {@link#ACTION_PACKAGE_REMOVED}*
- {@link#ACTION_PACKAGE_RESTARTED}*
- {@link#ACTION_PACKAGE_DATA_CLEARED}*
- {@link#ACTION_UID_REMOVED}*
- {@link#ACTION_BATTERY_CHANGED}*
- {@link#ACTION_POWER_CONNECTED}*
- {@link#ACTION_POWER_DISCONNECTED}*
- {@link#ACTION_SHUTDOWN}*
StandardCategories
**Thesearethecurrentstandardcategoriesthatcanbeusedtofurther*clarifyanIntentvia{@link#addCategory}.**
- *
- {@link#CATEGORY_DEFAULT}*
- {@link#CATEGORY_BROWSABLE}*
- {@link#CATEGORY_TAB}*
- {@link#CATEGORY_ALTERNATIVE}*
- {@link#CATEGORY_SELECTED_ALTERNATIVE}*
- {@link#CATEGORY_LAUNCHER}*
- {@link#CATEGORY_INFO}*
- {@link#CATEGORY_HOME}*
- {@link#CATEGORY_PREFERENCE}*
- {@link#CATEGORY_TEST}*
- {@link#CATEGORY_CAR_DOCK}*
- {@link#CATEGORY_DESK_DOCK}*
- {@link#CATEGORY_LE_DESK_DOCK}*
- {@link#CATEGORY_HE_DESK_DOCK}*
- {@link#CATEGORY_CAR_MODE}*
- {@link#CATEGORY_APP_MARKET}*
StandardExtraData
**Thesearethecurrentstandardfieldsthatcanbeusedasextradatavia*{@link#putExtra}.**
- *
- {@link#EXTRA_ALARM_COUNT}*
- {@link#EXTRA_BCC}*
- {@link#EXTRA_CC}*
- {@link#EXTRA_CHANGED_COMPONENT_NAME}*
- {@link#EXTRA_DATA_REMOVED}*
- {@link#EXTRA_DOCK_STATE}*
- {@link#EXTRA_DOCK_STATE_HE_DESK}*
- {@link#EXTRA_DOCK_STATE_LE_DESK}*
- {@link#EXTRA_DOCK_STATE_CAR}*
- {@link#EXTRA_DOCK_STATE_DESK}*
- {@link#EXTRA_DOCK_STATE_UNDOCKED}*
- {@link#EXTRA_DONT_KILL_APP}*
- {@link#EXTRA_EMAIL}*
- {@link#EXTRA_INITIAL_INTENTS}*
- {@link#EXTRA_INTENT}*
- {@link#EXTRA_KEY_EVENT}*
- {@link#EXTRA_PHONE_NUMBER}*
- {@link#EXTRA_REMOTE_INTENT_TOKEN}*
- {@link#EXTRA_REPLACING}*
- {@link#EXTRA_SHORTCUT_ICON}*
- {@link#EXTRA_SHORTCUT_ICON_RESOURCE}*
- {@link#EXTRA_SHORTCUT_INTENT}*
- {@link#EXTRA_STREAM}*
- {@link#EXTRA_SHORTCUT_NAME}*
- {@link#EXTRA_SUBJECT}*
- {@link#EXTRA_TEMPLATE}*
- {@link#EXTRA_TEXT}*
- {@link#EXTRA_TITLE}*
- {@link#EXTRA_UID}*
Flags
**ThesearethepossibleflagsthatcanbeusedintheIntentvia*{@link#setFlags}and{@link#addFlags}.See{@link#setFlags}foralist*ofallpossibleflags.*/publicclassIntentimplementsParcelable,Cloneable{//---------------------------------------------------------------------//---------------------------------------------------------------------//Standardintentactivityactions(seeactionvariable)./***ActivityAction:Startasamainentrypoint,doesnotexpectto*receivedata.*
Input:nothing*
Output:nothing*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_MAIN="android.intent.action.MAIN";/***ActivityAction:Displaythedatatotheuser.Thisisthemostcommon*actionperformedondata--itisthegenericactionyoucanuseon*apieceofdatatogetthemostreasonablethingtooccur.Forexample,*whenusedonacontactsentryitwillviewtheentry;whenusedona*mailto:URIitwillbringupacomposewindowfilledwiththeinformation*suppliedbytheURI;whenusedwithatel:URIitwillinvokethe*dialer.*
Input:{@link#getData}isURIfromwhichtoretrievedata.*
Output:nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_VIEW="android.intent.action.VIEW";/***Asynonymfor{@link#ACTION_VIEW},the"standard"actionthatis*performedonapieceofdata.*/publicstaticfinalStringACTION_DEFAULT=ACTION_VIEW;/***Usedtoindicatethatsomepieceofdatashouldbeattachedtosomeother*place.Forexample,imagedatacouldbeattachedtoacontact.Itisup*totherecipienttodecidewherethedatashouldbeattached;theintent*doesnotspecifytheultimatedestination.*
Input:{@link#getData}isURIofdatatobeattached.*
Output:nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_ATTACH_DATA="android.intent.action.ATTACH_DATA";/***ActivityAction:Provideexpliciteditableaccesstothegivendata.*
Input:{@link#getData}isURIofdatatobeedited.*
Output:nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_EDIT="android.intent.action.EDIT";/***ActivityAction:Pickanexistingitem,orinsertanewitem,andtheneditit.*
Input:{@link#getType}isthedesiredMIMEtypeoftheitemtocreateoredit.*Theextrascancontaintypespecificdatatopassthroughtotheediting/creating*activity.*
Output:TheURIoftheitemthatwaspicked.Thismustbeacontent:*URIsothatanyreceivercanaccessit.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_INSERT_OR_EDIT="android.intent.action.INSERT_OR_EDIT";/***ActivityAction:Pickanitemfromthedata,returningwhatwasselected.*
Input:{@link#getData}isURIcontainingadirectoryofdata*(vnd.android.cursor.dir/*)fromwhichtopickanitem.*
Output:TheURIoftheitemthatwaspicked.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_PICK="android.intent.action.PICK";/***ActivityAction:Createsashortcut.*
Input:Nothing.
*Output:AnIntentrepresentingtheshortcut.Theintentmustcontainthree*extras:SHORTCUT_INTENT(value:Intent),SHORTCUT_NAME(value:String),*andSHORTCUT_ICON(value:Bitmap)orSHORTCUT_ICON_RESOURCE*(value:ShortcutIconResource).
**@see#EXTRA_SHORTCUT_INTENT*@see#EXTRA_SHORTCUT_NAME*@see#EXTRA_SHORTCUT_ICON*@see#EXTRA_SHORTCUT_ICON_RESOURCE*@seeandroid.content.Intent.ShortcutIconResource*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_CREATE_SHORTCUT="android.intent.action.CREATE_SHORTCUT";/***ThenameoftheextrausedtodefinetheIntentofashortcut.**@see#ACTION_CREATE_SHORTCUT*/publicstaticfinalStringEXTRA_SHORTCUT_INTENT="android.intent.extra.shortcut.INTENT";/***Thenameoftheextrausedtodefinethenameofashortcut.**@see#ACTION_CREATE_SHORTCUT*/publicstaticfinalStringEXTRA_SHORTCUT_NAME="android.intent.extra.shortcut.NAME";/***Thenameoftheextrausedtodefinetheicon,asaBitmap,ofashortcut.**@see#ACTION_CREATE_SHORTCUT*/publicstaticfinalStringEXTRA_SHORTCUT_ICON="android.intent.extra.shortcut.ICON";/***Thenameoftheextrausedtodefinetheicon,asaShortcutIconResource,ofashortcut.**@see#ACTION_CREATE_SHORTCUT*@seeandroid.content.Intent.ShortcutIconResource*/publicstaticfinalStringEXTRA_SHORTCUT_ICON_RESOURCE="android.intent.extra.shortcut.ICON_RESOURCE";/***Representsashortcut/livefoldericonresource.**@seeIntent#ACTION_CREATE_SHORTCUT*@seeIntent#EXTRA_SHORTCUT_ICON_RESOURCE*@seeandroid.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER*@seeandroid.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON*/publicstaticclassShortcutIconResourceimplementsParcelable{/***Thepackagenameoftheapplicationcontainingtheicon.*/publicStringpackageName;/***Theresourcenameoftheicon,includingpackage,nameandtype.*/publicStringresourceName;/***CreatesanewShortcutIconResourceforthespecifiedcontextandresource*identifier.**@paramcontextThecontextoftheapplication.*@paramresourceIdTheresourceidenfitierfortheicon.*@returnAnewShortcutIconResourcewiththespecified'scontextpackagename*andiconresourceidenfitier.*/publicstaticShortcutIconResourcefromContext(Contextcontext,intresourceId){ShortcutIconResourceicon=newShortcutIconResource();icon.packageName=context.getPackageName();icon.resourceName=context.getResources().getResourceName(resourceId);returnicon;}/***UsedtoreadaShortcutIconResourcefromaParcel.*/publicstaticfinalParcelable.Creator- *
- Youcanspecifythetitlethatwillappearintheactivitychooser.*
- Theuserdoesnothavetheoptiontomakeoneofthematching*activitiesapreferredactivity,andallpossibleactivitieswill*alwaysbeshownevenifoneofthemiscurrentlymarkedasthe*preferredactivity.*
*Thisactionshouldbeusedwhentheuserwillnaturallyexpectto*selectanactivityinordertoproceed.Anexampleifwhennottouse*itiswhentheuserclicksona"mailto:"link.Theywouldnaturally*expecttogodirectlytotheirmailapp,sostartActivity()shouldbe*calleddirectly:itwill*eitherlaunchthecurrentpreferredapp,orputupadialogallowingthe*usertopickanapptouseandoptionallymarkingthataspreferred.*
*Incontrast,iftheuserisselectingamenuitemtosendapicture*theyareviewingtosomeoneelse,therearemanydifferentthingsthey*maywanttodoatthispoint:senditthroughe-mail,uploadittoa*webservice,etc.InthiscasetheCHOOSERactionshouldbeused,to*alwayspresenttotheuseralistofthethingstheycando,witha*nicetitlegivenbythecallersuchas"Sendthisphotowith:".*
*Asaconvenience,anIntentofthisformcanbecreatedwiththe*{@link#createChooser}function.*
Input:Nodatashouldbespecified.get*Extramusthave*a{@link#EXTRA_INTENT}fieldcontainingtheIntentbeingexecuted,*andcanoptionallyhavea{@link#EXTRA_TITLE}fieldcontainingthe*titletexttodisplayinthechooser.*
Output:Dependsontheprotocolof{@link#EXTRA_INTENT}.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_CHOOSER="android.intent.action.CHOOSER";/***Conveniencefunctionforcreatinga{@link#ACTION_CHOOSER}Intent.**@paramtargetTheIntentthattheuserwillbeselectinganactivity*toperform.*@paramtitleOptionaltitlethatwillbedisplayedinthechooser.*@returnReturnanewIntentobjectthatyoucanhandto*{@linkContext#startActivity(Intent)Context.startActivity()}and*relatedmethods.*/publicstaticIntentcreateChooser(Intenttarget,CharSequencetitle){Intentintent=newIntent(ACTION_CHOOSER);intent.putExtra(EXTRA_INTENT,target);if(title!=null){intent.putExtra(EXTRA_TITLE,title);}returnintent;}/***ActivityAction:Allowtheusertoselectaparticularkindofdataand*returnit.Thisisdifferentthan{@link#ACTION_PICK}inthatherewe*justsaywhatkindofdataisdesired,notaURIofexistingdatafrom*whichtheusercanpick.AACTION_GET_CONTENTcouldallowtheuserto*createthedataasitruns(forexampletakingapictureorrecordinga*sound),letthembrowseoverthewebanddownloadthedesireddata,*etc.*
*Therearetwomainwaystousethisaction:ifyouwantaspecifickind*ofdata,suchasapersoncontact,yousettheMIMEtypetothekindof*datayouwantandlaunchitwith{@linkContext#startActivity(Intent)}.*Thesystemwillthenlaunchthebestapplicationtoselectthatkind*ofdataforyou.*
*Youmayalsobeinterestedinanyofasetoftypesofcontenttheuser*canpick.Forexample,ane-mailapplicationthatwantstoallowthe*usertoaddanattachmenttoane-mailmessagecanusethisactionto*bringupalistofallofthetypesofcontenttheusercanattach.*
*Inthiscase,youshouldwraptheGET_CONTENTintentwithachooser*(through{@link#createChooser}),whichwillgivetheproperinterface*fortheusertopickhowtosendyourdataandallowyoutospecify*apromptindicatingwhattheyaredoing.Youwillusuallyspecifya*broadMIMEtype(suchasimage/*or{@literal*}/*),resultingina*broadrangeofcontenttypestheusercanselectfrom.*
*WhenusingsuchabroadGET_CONTENTaction,itisoftendesirableto*onlypickfromdatathatcanberepresentedasastream.Thisis*accomplishedbyrequiringthe{@link#CATEGORY_OPENABLE}intheIntent.*
*Callerscanoptionallyspecify{@link#EXTRA_LOCAL_ONLY}torequestthat*thelaunchedcontentchooseronlyreturnsresultsrepresentingdatathat*islocallyavailableonthedevice.Forexample,ifthisextraisset*totruethenanimagepickershouldnotshowanypicturesthatareavailable*fromaremoteserverbutnotalreadyonthelocaldevice(thusrequiring*theybedownloadedwhenopened).*
*Input:{@link#getType}isthedesiredMIMEtypetoretrieve.Note*thatnoURIissuppliedintheintent,astherearenoconstraintson*wherethereturneddataoriginallycomesfrom.Youmayalsoincludethe*{@link#CATEGORY_OPENABLE}ifyoucanonlyacceptdatathatcanbe*openedasastream.Youmayuse{@link#EXTRA_LOCAL_ONLY}tolimitcontent*selectiontolocaldata.*
*Output:TheURIoftheitemthatwaspicked.Thismustbeacontent:*URIsothatanyreceivercanaccessit.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_GET_CONTENT="android.intent.action.GET_CONTENT";/***ActivityAction:Dialanumberasspecifiedbythedata.Thisshowsa*UIwiththenumberbeingdialed,allowingtheusertoexplicitly*initiatethecall.*
Input:Ifnothing,anemptydialerisstarted;else{@link#getData}*isURIofaphonenumbertobedialedoratel:URIofanexplicitphone*number.*
Output:nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_DIAL="android.intent.action.DIAL";/***ActivityAction:Performacalltosomeonespecifiedbythedata.*
Input:Ifnothing,anemptydialerisstarted;else{@link#getData}*isURIofaphonenumbertobedialedoratel:URIofanexplicitphone*number.*
Output:nothing.**
Note:therewillberestrictionsonwhichapplicationscaninitiatea*call;mostapplicationsshouldusethe{@link#ACTION_DIAL}.*
Note:thisIntentcannotbeusedtocallemergency*numbers.Applicationscandialemergencynumbersusing*{@link#ACTION_DIAL},however.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_CALL="android.intent.action.CALL";/***ActivityAction:Performacalltoanemergencynumberspecifiedbythe*data.*
Input:{@link#getData}isURIofaphonenumbertobedialedora*tel:URIofanexplicitphonenumber.*
Output:nothing.*@hide*/publicstaticfinalStringACTION_CALL_EMERGENCY="android.intent.action.CALL_EMERGENCY";/***Activityaction:Performacalltoanynumber(emergencyornot)*specifiedbythedata.*
Input:{@link#getData}isURIofaphonenumbertobedialedora*tel:URIofanexplicitphonenumber.*
Output:nothing.*@hide*/publicstaticfinalStringACTION_CALL_PRIVILEGED="android.intent.action.CALL_PRIVILEGED";/***ActivityAction:Sendamessagetosomeonespecifiedbythedata.*
Input:{@link#getData}isURIdescribingthetarget.*
Output:nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_SENDTO="android.intent.action.SENDTO";/***ActivityAction:Deliversomedatatosomeoneelse.Whothedatais*beingdeliveredtoisnotspecified;itisuptothereceiverofthis*actiontoasktheuserwherethedatashouldbesent.*
*WhenlaunchingaSENDintent,youshouldusuallywrapitinachooser*(through{@link#createChooser}),whichwillgivetheproperinterface*fortheusertopickhowtosendyourdataandallowyoutospecify*apromptindicatingwhattheyaredoing.*
*Input:{@link#getType}istheMIMEtypeofthedatabeingsent.*get*Extracanhaveeithera{@link#EXTRA_TEXT}*or{@link#EXTRA_STREAM}field,containingthedatatobesent.If*usingEXTRA_TEXT,theMIMEtypeshouldbe"text/plain";otherwiseit*shouldbetheMIMEtypeofthedatainEXTRA_STREAM.Use{@literal*}/**iftheMIMEtypeisunknown(thiswillonlyallowsendersthatcan*handlegenericdatastreams).*
*Optionalstandardextras,whichmaybeinterpretedbysomerecipientsas*appropriate,are:{@link#EXTRA_EMAIL},{@link#EXTRA_CC},*{@link#EXTRA_BCC},{@link#EXTRA_SUBJECT}.*
*Output:nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_SEND="android.intent.action.SEND";/***ActivityAction:Delivermultipledatatosomeoneelse.*
*LikeACTION_SEND,exceptthedataismultiple.*
*Input:{@link#getType}istheMIMEtypeofthedatabeingsent.*get*ArrayListExtracanhaveeithera{@link#EXTRA_TEXT}or{@link*#EXTRA_STREAM}field,containingthedatatobesent.*
*Multipletypesaresupported,andreceiversshouldhandlemixedtypes*wheneverpossible.Therightwayforthereceivertocheckthemisto*usethecontentresolveroneachURI.Theintentsendershouldtryto*putthemostconcretemimetypeintheintenttype,butitcanfall*backto{@literal *e.g.ifyouaresendingimage/jpgandimage/jpg,theintent'stypecan*beimage/jpg,butifyouaresendingimage/jpgandimage/png,thenthe*intent'stypeshouldbeimage/*.* *Optionalstandardextras,whichmaybeinterpretedbysomerecipientsas*appropriate,are:{@link#EXTRA_EMAIL},{@link#EXTRA_CC},*{@link#EXTRA_BCC},{@link#EXTRA_SUBJECT}.* *Output:nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_SEND_MULTIPLE="android.intent.action.SEND_MULTIPLE";/***ActivityAction:Handleanincomingphonecall.* Input:nothing.* Output:nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_ANSWER="android.intent.action.ANSWER";/***ActivityAction:Insertanemptyitemintothegivencontainer.* Input:{@link#getData}isURIofthedirectory(vnd.android.cursor.dir/*)*inwhichtoplacethedata.* Output:URIofthenewdatathatwascreated.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_INSERT="android.intent.action.INSERT";/***ActivityAction:Createanewiteminthegivencontainer,initializingit*fromthecurrentcontentsoftheclipboard.* Input:{@link#getData}isURIofthedirectory(vnd.android.cursor.dir/*)*inwhichtoplacethedata.* Output:URIofthenewdatathatwascreated.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_PASTE="android.intent.action.PASTE";/***ActivityAction:Deletethegivendatafromitscontainer.* Input:{@link#getData}isURIofdatatobedeleted.* Output:nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_DELETE="android.intent.action.DELETE";/***ActivityAction:Runthedata,whateverthatmeans.* Input:?(Note:thisiscurrentlyspecifictothetestharness.)* Output:nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_RUN="android.intent.action.RUN";/***ActivityAction:Performadatasynchronization.* Input:?* Output:?*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_SYNC="android.intent.action.SYNC";/***ActivityAction:Pickanactivitygivenanintent,returningtheclass*selected.* Input:get*Extrafield{@link#EXTRA_INTENT}isanIntent*usedwith{@linkPackageManager#queryIntentActivities}todeterminethe*setofactivitiesfromwhichtopick.* Output:Classnameoftheactivitythatwasselected.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_PICK_ACTIVITY="android.intent.action.PICK_ACTIVITY";/***ActivityAction:Performasearch.* Input:{@linkandroid.app.SearchManager#QUERYgetStringExtra(SearchManager.QUERY)}*isthetexttosearchfor.Ifempty,simply*enteryoursearchresultsActivitywiththesearchUIactivated.* Output:nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_SEARCH="android.intent.action.SEARCH";/***ActivityAction:Starttheplatform-definedtutorial* Input:{@linkandroid.app.SearchManager#QUERYgetStringExtra(SearchManager.QUERY)}*isthetexttosearchfor.Ifempty,simply*enteryoursearchresultsActivitywiththesearchUIactivated.* Output:nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_SYSTEM_TUTORIAL="android.intent.action.SYSTEM_TUTORIAL";/***ActivityAction:Performawebsearch.* *Input:{@linkandroid.app.SearchManager#QUERY*getStringExtra(SearchManager.QUERY)}isthetexttosearchfor.Ifitis*aurlstartswithhttporhttps,thesitewillbeopened.Ifitisplain*text,Googlesearchwillbeapplied.* *Output:nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_WEB_SEARCH="android.intent.action.WEB_SEARCH";/***ActivityAction:Listallavailableapplications* Input:Nothing.* Output:nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_ALL_APPS="android.intent.action.ALL_APPS";/***ActivityAction:Showsettingsforchoosingwallpaper* Input:Nothing.* Output:Nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_SET_WALLPAPER="android.intent.action.SET_WALLPAPER";/***ActivityAction:Showactivityforreportingabug.* Input:Nothing.* Output:Nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_BUG_REPORT="android.intent.action.BUG_REPORT";/***ActivityAction:Mainentrypointforfactorytests.Onlyusedwhen*thedeviceisbootinginfactorytestnode.Theimplementingpackage*mustbeinstalledinthesystemimage.* Input:nothing* Output:nothing*/publicstaticfinalStringACTION_FACTORY_TEST="android.intent.action.FACTORY_TEST";/***ActivityAction:Theuserpressedthe"call"buttontogotothedialer*orotherappropriateUIforplacingacall.* Input:Nothing.* Output:Nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_CALL_BUTTON="android.intent.action.CALL_BUTTON";/***ActivityAction:StartVoiceCommand.* Input:Nothing.* Output:Nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_VOICE_COMMAND="android.intent.action.VOICE_COMMAND";/***ActivityAction:Startactionassociatedwithlongpressingonthe*searchkey.* Input:Nothing.* Output:Nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_SEARCH_LONG_PRESS="android.intent.action.SEARCH_LONG_PRESS";/***ActivityAction:Theuserpressedthe"Report"buttoninthecrash/ANRdialog.*Thisintentisdeliveredtothepackagewhichinstalledtheapplication,usually*GooglePlay.* Input:Nodataisspecified.Thebugreportispassedinusing*an{@link#EXTRA_BUG_REPORT}field.* Output:Nothing.**@see#EXTRA_BUG_REPORT*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_APP_ERROR="android.intent.action.APP_ERROR";/***ActivityAction:Showpowerusageinformationtotheuser.* Input:Nothing.* Output:Nothing.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_POWER_USAGE_SUMMARY="android.intent.action.POWER_USAGE_SUMMARY";/***ActivityAction:Setupwizardtolaunchafteraplatformupdate.This*activityshouldhaveastringmeta-datafieldassociatedwithit,*{@link#METADATA_SETUP_VERSION},whichdefinesthecurrentversionof*theplatformforsetup.Theactivitywillbelaunchedonlyif*{@linkandroid.provider.Settings.Secure#LAST_SETUP_SHOWN}isnotthe*samevalue.* Input:Nothing.* Output:Nothing.*@hide*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_UPGRADE_SETUP="android.intent.action.UPGRADE_SETUP";/***ActivityAction:Showsettingsformanagingnetworkdatausageofa*specificapplication.Applicationsshoulddefineanactivitythatoffers*optionstocontroldatausage.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_MANAGE_NETWORK_USAGE="android.intent.action.MANAGE_NETWORK_USAGE";/***ActivityAction:Launchapplicationinstaller.* *Input:Thedatamustbeacontent:orfile:URIatwhichtheapplication*canberetrieved.Youcanoptionallysupply*{@link#EXTRA_INSTALLER_PACKAGE_NAME},{@link#EXTRA_NOT_UNKNOWN_SOURCE},*{@link#EXTRA_ALLOW_REPLACE},and{@link#EXTRA_RETURN_RESULT}.* *Output:If{@link#EXTRA_RETURN_RESULT},returnswhethertheinstall*succeeded.**@see#EXTRA_INSTALLER_PACKAGE_NAME*@see#EXTRA_NOT_UNKNOWN_SOURCE*@see#EXTRA_RETURN_RESULT*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_INSTALL_PACKAGE="android.intent.action.INSTALL_PACKAGE";/***Usedasastringextrafieldwith{@link#ACTION_INSTALL_PACKAGE}toinstalla*package.Specifiestheinstallerpackagename;thispackagewillreceivethe*{@link#ACTION_APP_ERROR}intent.*/publicstaticfinalStringEXTRA_INSTALLER_PACKAGE_NAME="android.intent.extra.INSTALLER_PACKAGE_NAME";/***Usedasabooleanextrafieldwith{@link#ACTION_INSTALL_PACKAGE}toinstalla*package.Specifiesthattheapplicationbeinginstalledshouldnotbe*treatedascomingfromanunknownsource,butascomingfromtheapp*invokingtheIntent.Forthistoworkyoumuststarttheinstallerwith*startActivityForResult().*/publicstaticfinalStringEXTRA_NOT_UNKNOWN_SOURCE="android.intent.extra.NOT_UNKNOWN_SOURCE";/***Usedasabooleanextrafieldwith{@link#ACTION_INSTALL_PACKAGE}toinstalla*package.TellstheinstallerUItoskiptheconfirmationwiththeuser*ifthe.apkisreplacinganexistingone.*/publicstaticfinalStringEXTRA_ALLOW_REPLACE="android.intent.extra.ALLOW_REPLACE";/***Usedasabooleanextrafieldwith{@link#ACTION_INSTALL_PACKAGE}or*{@link#ACTION_UNINSTALL_PACKAGE}.SpecifiesthattheinstallerUIshould*returntotheapplicationtheresultcodeoftheinstall/uninstall.Thereturnedresult*codewillbe{@linkandroid.app.Activity#RESULT_OK}onsuccessor*{@linkandroid.app.Activity#RESULT_FIRST_USER}onfailure.*/publicstaticfinalStringEXTRA_RETURN_RESULT="android.intent.extra.RETURN_RESULT";/***Packagemanagerinstallresultcode.@hidebecauseresultcodesarenot*yetreadytobeexposed.*/publicstaticfinalStringEXTRA_INSTALL_RESULT="android.intent.extra.INSTALL_RESULT";/***ActivityAction:Launchapplicationuninstaller.* *Input:Thedatamustbeapackage:URIwhoseschemespecificpartis*thepackagenameofthecurrentinstalledpackagetobeuninstalled.*Youcanoptionallysupply{@link#EXTRA_RETURN_RESULT}.* *Output:If{@link#EXTRA_RETURN_RESULT},returnswhethertheinstall*succeeded.*/@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)publicstaticfinalStringACTION_UNINSTALL_PACKAGE="android.intent.action.UNINSTALL_PACKAGE";/***Astringassociatedwitha{@link#ACTION_UPGRADE_SETUP}activity*describingthelastrunversionoftheplatformthatwassetup.*@hide*/publicstaticfinalStringMETADATA_SETUP_VERSION="android.SETUP_VERSION";//---------------------------------------------------------------------//---------------------------------------------------------------------//Standardintentbroadcastactions(seeactionvariable)./***BroadcastAction:Sentafterthescreenturnsoff.** Input:{@link#getData}istheURIofthepackagefiletodownload.** Myincludethefollowingextras:* Myincludethefollowingextras:* Includesthefollowingextras:* Incluesthefollowingextras:* BroadcastAction:TheuserhasswitchedthephoneintooroutofAirplaneMode.Oneor*moreradioshavebeenturnedofforon.Theintentwillhavethefollowingextravalue: Thedataoftheintentidentifieswhichpartofwhichprovider*changed.Whenqueriedthroughthecontentresolver,thedataURIwill*returnthedatasetinquestion.** Theintentwillhavethefollowingextravalues:* Theintentwillhavethefollowingextravalues:* Theintentwillhavethefollowingextravalues:* Theintentwillhavethefollowingextravalues:* Theintentwillhavethefollowingextravalues:* BroadcastAction:Theuserhasswitchedonadvancedsettingsinthesettingsapp: TheIntentwillhavethefollowingextravalue:* Oncethebroadcastisfinished,theresultDataisusedastheactual*numbertocall.If Itisperfectlyacceptableformultiplereceiverstoprocessthe*outgoingcallinturn:forexample,aparentalcontrolapplication*mightverifythattheuserisauthorizedtoplacethecallatthat*time,thenanumber-rewritingapplicationmightaddanareacodeif*onewasnotspecified. Forconsistency,anyreceiverwhosepurposeistoprohibitphone*callsshouldhaveapriorityof0,toensureitwillseethefinal*phonenumbertobedialed.*Anyreceiverwhosepurposeistorewritephonenumberstobecalled*shouldhaveapositivepriority.*Negativeprioritiesarereservedforthesystemforthisbroadcast;*usingthemmaycauseproblems. AnyBroadcastReceiverreceivingthisIntentmustnot*abortthebroadcast. Emergencycallscannotbeinterceptedusingthismechanism,and*othercallscannotbemodifiedtocallemergencynumbersusingthis*mechanism.* Youmustholdthe*{@linkandroid.Manifest.permission#PROCESS_OUTGOING_CALLS}*permissiontoreceivethisIntent. Theintentwillhavethefollowingextravalues:* Thisisintendedformonitoringthecurrentphysicaldockstate.*See{@linkandroid.app.UiModeManager}forthenormalAPIdealingwith*dockmodechanges.*/@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)publicstaticfinalStringACTION_DOCK_EVENT="android.intent.action.DOCK_EVENT";/***BroadcastAction:aremoteintentistobebroadcasted.**AremoteintentisusedforremoteRPCbetweendevices.Theremoteintent*isserializedandsentfromonedevicetoanotherdevice.Thereceiving*deviceparsestheremoteintentandbroadcastsit.Notethatanyonecan*broadcastaremoteintent.However,iftheintentreceiveroftheremoteintent*doesnottrustintentbroadcastsfromarbitraryintentsenders,itshouldrequire*thesendertoholdcertainpermissionssoonlytrustedsender'sbroadcastwillbe*letthrough.*@hide*/publicstaticfinalStringACTION_REMOTE_INTENT="com.google.android.c2dm.intent.RECEIVE";/***BroadcastAction:hookforpermformingcleanupafterasystemupdate.**Thebroadcastissentwhenthesystemisbooting,beforethe*BOOT_COMPLETEDbroadcast.Itisonlysenttoreceiversinthesystem*image.Areceiverforthisshoulddoitsworkandthendisableitself*sothatitdoesnotgetrunagainatthenextboot.*@hide*/publicstaticfinalStringACTION_PRE_BOOT_COMPLETED="android.intent.action.PRE_BOOT_COMPLETED";/***Broadcastsenttothesystemwhenauserisadded.CarriesanextraEXTRA_USERIDthathasthe*useridofthenewuser.*@hide*/publicstaticfinalStringACTION_USER_ADDED="android.intent.action.USER_ADDED";/***Broadcastsenttothesystemwhenauserisremoved.CarriesanextraEXTRA_USERIDthathas*theuseridoftheuser.*@hide*/publicstaticfinalStringACTION_USER_REMOVED="android.intent.action.USER_REMOVED";/***Broadcastsenttothesystemwhentheuserswitches.CarriesanextraEXTRA_USERIDthathas*theuseridoftheusertobecomethecurrentone.*@hide*/publicstaticfinalStringACTION_USER_SWITCHED="android.intent.action.USER_SWITCHED";//---------------------------------------------------------------------//---------------------------------------------------------------------//Standardintentcategories(seeaddCategory())./***Setiftheactivityshouldbeanoptionforthedefaultaction*(centerpress)toperformonapieceofdata.Settingthiswill*hidefromtheuseranyactivitieswithoutitsetwhenperformingan*actiononsomedata.Notethatthisisnormal-not-setinthe*Intentwheninitiatinganaction--itisforuseinintentfilters*specifiedinpackages.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_DEFAULT="android.intent.category.DEFAULT";/***Activitiesthatcanbesafelyinvokedfromabrowsermustsupportthis*category.Forexample,iftheuserisviewingawebpageorane-mail*andclicksonalinkinthetext,theIntentgeneratedexecutethat*linkwillrequiretheBROWSABLEcategory,sothatonlyactivities*supportingthiscategorywillbeconsideredaspossibleactions.By*supportingthiscategory,youarepromisingthatthereisnothing*damaging(withoutuserintervention)thatcanhappenbyinvokingany*matchingIntent.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_BROWSABLE="android.intent.category.BROWSABLE";/***Setiftheactivityshouldbeconsideredasanalternativeactionto*thedatatheuseriscurrentlyviewing.Seealso*{@link#CATEGORY_SELECTED_ALTERNATIVE}foranalternativeactionthat*appliestotheselectioninalistofitems.** Supportingthiscategorymeansthatyouwouldlikeyouractivitytobe*displayedinthesetofalternativethingstheusercando,usuallyas*partofthecurrentactivity'soptionsmenu.Youwillusuallywantto*includeaspecificlabelinthe<intent-filter>ofthisaction*describingtotheuserwhatitdoes.** TheactionofIntentFilterwiththiscategoryisimportantinthatit*describesthespecificactionthetargetwillperform.Thisgenerally*shouldnotbeagenericaction(suchas{@link#ACTION_VIEW},butrather*aspecificnamesuchas"com.android.camera.action.CROP.Onlyone*alternativeofanyparticularactionwillbeshowntotheuser,sousing*aspecificactionlikethismakessurethatyouralternativewillbe*displayedwhilealsoallowingotherapplicationstoprovidetheirown*overridesofthatparticularaction.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_ALTERNATIVE="android.intent.category.ALTERNATIVE";/***Setiftheactivityshouldbeconsideredasanalternativeselection*actiontothedatatheuserhascurrentlyselected.Thisislike*{@link#CATEGORY_ALTERNATIVE},butisusedinactivitiesshowingalist*ofitemsfromwhichtheusercanselect,givingthemalternativestothe*defaultactionthatwillbeperformedonit.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_SELECTED_ALTERNATIVE="android.intent.category.SELECTED_ALTERNATIVE";/***IntendedtobeusedasatabinsideofacontainingTabActivity.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_TAB="android.intent.category.TAB";/***Shouldbedisplayedinthetop-levellauncher.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_LAUNCHER="android.intent.category.LAUNCHER";/***Providesinformationaboutthepackageitisin;typicallyusedif*apackagedoesnotcontaina{@link#CATEGORY_LAUNCHER}toprovide*afront-doortotheuserwithouthavingtobeshownintheallappslist.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_INFO="android.intent.category.INFO";/***Thisisthehomeactivity,thatisthefirstactivitythatisdisplayed*whenthedeviceboots.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_HOME="android.intent.category.HOME";/***Thisactivityisapreferencepanel.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_PREFERENCE="android.intent.category.PREFERENCE";/***Thisactivityisadevelopmentpreferencepanel.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_DEVELOPMENT_PREFERENCE="android.intent.category.DEVELOPMENT_PREFERENCE";/***Capableofrunninginsideaparentactivitycontainer.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_EMBED="android.intent.category.EMBED";/***Thisactivityallowstheusertobrowseanddownloadnewapplications.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_APP_MARKET="android.intent.category.APP_MARKET";/***Thisactivitymaybeexercisedbythemonkeyorotherautomatedtesttools.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_MONKEY="android.intent.category.MONKEY";/***Tobeusedasatest(notpartofthenormaluserexperience).*/publicstaticfinalStringCATEGORY_TEST="android.intent.category.TEST";/***Tobeusedasaunittest(runthroughtheTestHarness).*/publicstaticfinalStringCATEGORY_UNIT_TEST="android.intent.category.UNIT_TEST";/***Tobeusedasasamplecodeexample(notpartofthenormaluser*experience).*/publicstaticfinalStringCATEGORY_SAMPLE_CODE="android.intent.category.SAMPLE_CODE";/***UsedtoindicatethataGET_CONTENTintentonlywantsURIsthatcanbeopenedwith*ContentResolver.openInputStream.OpenableURIsmustsupportthecolumnsinOpenableColumns*whenqueried,thoughitisallowableforthosecolumnstobeblank.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_OPENABLE="android.intent.category.OPENABLE";/***Tobeusedascodeundertestforframeworkinstrumentationtests.*/publicstaticfinalStringCATEGORY_FRAMEWORK_INSTRUMENTATION_TEST="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";/***Anactivitytorunwhendeviceisinsertedintoacardock.*Usedwith{@link#ACTION_MAIN}tolaunchanactivity.Formore*information,see{@linkandroid.app.UiModeManager}.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_CAR_DOCK="android.intent.category.CAR_DOCK";/***Anactivitytorunwhendeviceisinsertedintoacardock.*Usedwith{@link#ACTION_MAIN}tolaunchanactivity.Formore*information,see{@linkandroid.app.UiModeManager}.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_DESK_DOCK="android.intent.category.DESK_DOCK";/***Anactivitytorunwhendeviceisinsertedintoaanalog(lowend)dock.*Usedwith{@link#ACTION_MAIN}tolaunchanactivity.Formore*information,see{@linkandroid.app.UiModeManager}.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_LE_DESK_DOCK="android.intent.category.LE_DESK_DOCK";/***Anactivitytorunwhendeviceisinsertedintoadigital(highend)dock.*Usedwith{@link#ACTION_MAIN}tolaunchanactivity.Formore*information,see{@linkandroid.app.UiModeManager}.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_HE_DESK_DOCK="android.intent.category.HE_DESK_DOCK";/***Usedtoindicatethattheactivitycanbeusedinacarenvironment.*/@SdkConstant(SdkConstantType.INTENT_CATEGORY)publicstaticfinalStringCATEGORY_CAR_MODE="android.intent.category.CAR_MODE";//---------------------------------------------------------------------//---------------------------------------------------------------------//Applicationlaunchintentcategories(seeaddCategory())./***Usedwith{@link#ACTION_MAIN}tolaunchthebrowserapplication.*TheactivityshouldbeabletobrowsetheInternet.* NOTE:ThisshouldnotbeusedastheprimarykeyofanIntent,*sinceitwillnotresultintheapplaunchingwiththecorrect*actionandcategory.Instead,usethiswith*{@link#makeMainSelectorActivity(String,String)}togenerateamain*Intentwiththiscategoryintheselector. NOTE:ThisshouldnotbeusedastheprimarykeyofanIntent,*sinceitwillnotresultintheapplaunchingwiththecorrect*actionandcategory.Instead,usethiswith*{@link#makeMainSelectorActivity(String,String)}togenerateamain*Intentwiththiscategoryintheselector. NOTE:ThisshouldnotbeusedastheprimarykeyofanIntent,*sinceitwillnotresultintheapplaunchingwiththecorrect*actionandcategory.Instead,usethiswith*{@link#makeMainSelectorActivity(String,String)}togenerateamain*Intentwiththiscategoryintheselector. NOTE:ThisshouldnotbeusedastheprimarykeyofanIntent,*sinceitwillnotresultintheapplaunchingwiththecorrect*actionandcategory.Instead,usethiswith*{@link#makeMainSelectorActivity(String,String)}togenerateamain*Intentwiththiscategoryintheselector. NOTE:ThisshouldnotbeusedastheprimarykeyofanIntent,*sinceitwillnotresultintheapplaunchingwiththecorrect*actionandcategory.Instead,usethiswith*{@link#makeMainSelectorActivity(String,String)}togenerateamain*Intentwiththiscategoryintheselector. NOTE:ThisshouldnotbeusedastheprimarykeyofanIntent,*sinceitwillnotresultintheapplaunchingwiththecorrect*actionandcategory.Instead,usethiswith*{@link#makeMainSelectorActivity(String,String)}togenerateamain*Intentwiththiscategoryintheselector. NOTE:ThisshouldnotbeusedastheprimarykeyofanIntent,*sinceitwillnotresultintheapplaunchingwiththecorrect*actionandcategory.Instead,usethiswith*{@link#makeMainSelectorActivity(String,String)}togenerateamain*Intentwiththiscategoryintheselector. NOTE:ThisshouldnotbeusedastheprimarykeyofanIntent,*sinceitwillnotresultintheapplaunchingwiththecorrect*actionandcategory.Instead,usethiswith*{@link#makeMainSelectorActivity(String,String)}togenerateamain*Intentwiththiscategoryintheselector. NOTE:ThisshouldnotbeusedastheprimarykeyofanIntent,*sinceitwillnotresultintheapplaunchingwiththecorrect*actionandcategory.Instead,usethiswith*{@link#makeMainSelectorActivity(String,String)}togenerateamain*Intentwiththiscategoryintheselector. Thisflagisgenerallyusedbyactivitiesthatwant*topresenta"launcher"stylebehavior:theygivetheuseralistof*separatethingsthatcanbedone,whichotherwiseruncompletely*independentlyoftheactivitylaunchingthem.** Whenusingthisflag,ifataskisalreadyrunningfortheactivity*youarenowstarting,thenanewactivitywillnotbestarted;instead,*thecurrenttaskwillsimplybebroughttothefrontofthescreenwith*thestateitwaslastin.See{@link#FLAG_ACTIVITY_MULTIPLE_TASK}foraflag*todisablethisbehavior.** Thisflagcannotbeusedwhenthecallerisrequestingaresultfrom*theactivitybeinglaunched.*/publicstaticfinalintFLAG_ACTIVITY_NEW_TASK=0x10000000;/***Donotusethisflagunlessyouareimplementingyourown*top-levelapplicationlauncher.Usedinconjunctionwith*{@link#FLAG_ACTIVITY_NEW_TASK}todisablethe*behaviorofbringinganexistingtasktotheforeground.Whenset,*anewtaskisalwaysstartedtohosttheActivityforthe*Intent,regardlessofwhetherthereisalreadyanexistingtaskrunning*thesamething.** Becausethedefaultsystemdoesnotincludegraphicaltaskmanagement,*youshouldnotusethisflagunlessyouprovidesomewayforauserto*returnbacktothetasksyouhavelaunched.** Thisflagisignoredif*{@link#FLAG_ACTIVITY_NEW_TASK}isnotset.** See* Forexample,considerataskconsistingoftheactivities:A,B,C,D.*IfDcallsstartActivity()withanIntentthatresolvestothecomponent*ofactivityB,thenCandDwillbefinishedandBreceivethegiven*Intent,resultinginthestacknowbeing:A,B.** ThecurrentlyrunninginstanceofactivityBintheaboveexamplewill*eitherreceivethenewintentyouarestartinghereinits*onNewIntent()method,orbeitselffinishedandrestartedwiththe*newintent.Ifithasdeclareditslaunchmodetobe"multiple"(the*default)andyouhavenotset{@link#FLAG_ACTIVITY_SINGLE_TOP}in*thesameintent,thenitwillbefinishedandre-created;forallother*launchmodesorif{@link#FLAG_ACTIVITY_SINGLE_TOP}issetthenthis*Intentwillbedeliveredtothecurrentinstance'sonNewIntent().** Thislaunchmodecanalsobeusedtogoodeffectinconjunctionwith*{@link#FLAG_ACTIVITY_NEW_TASK}:ifusedtostarttherootactivity*ofatask,itwillbringanycurrentlyrunninginstanceofthattask*totheforeground,andthenclearittoitsrootstate.Thisis*especiallyuseful,forexample,whenlaunchinganactivityfromthe*notificationmanager.** See* Thisisusefulforcaseswhereyouhavealogicalbreakinyour*application.Forexample,ane-mailapplicationmayhaveacommand*toviewanattachment,whichlaunchesanimageviewactivityto*displayit.Thisactivityshouldbepartofthee-mailapplication's*task,sinceitisapartofthetasktheuserisinvolvedin.However,*iftheuserleavesthattask,andlaterselectsthee-mailappfrom*home,wemaylikethemtoreturntotheconversationtheywere*viewing,notthepictureattachment,sincethatisconfusing.By*settingthisflagwhenlaunchingtheimageviewer,thatviewerand*anyactivitiesitstartswillberemovedthenexttimetheuserreturns*tomail.*/publicstaticfinalintFLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET=0x00080000;/***Ifset,thisflagwillpreventthenormal{@linkandroid.app.Activity#onUserLeaveHint}*callbackfromoccurringonthecurrentfrontmostactivitybeforeitis*pausedasthenewly-startedactivityisbroughttothefront.** Typically,anactivitycanrelyonthatcallbacktoindicatethatan*explicituseractionhascausedtheiractivitytobemovedoutofthe*foreground.Thecallbackmarksanappropriatepointintheactivity's*lifecycleforittodismissanynotificationsthatitintendstodisplay*"untiltheuserhasseenthem,"suchasablinkingLED.** Ifanactivityiseverstartedviaanynon-user-driveneventssuchas*phone-callreceiptoranalarmhandler,thisflagshouldbepassedto{@link*Context#startActivityContext.startActivity},ensuringthatthepausing*activitydoesnotthinktheuserhasacknowledgeditsnotification.*/publicstaticfinalintFLAG_ACTIVITY_NO_USER_ACTION=0x00040000;/***IfsetinanIntentpassedto{@linkContext#startActivityContext.startActivity()},*thisflagwillcausethelaunchedactivitytobebroughttothefrontofits*task'shistorystackifitisalreadyrunning.** Forexample,considerataskconsistingoffouractivities:A,B,C,D.*IfDcallsstartActivity()withanIntentthatresolvestothecomponent*ofactivityB,thenBwillbebroughttothefrontofthehistorystack,*withthisresultingorder:A,C,D,B.**Thisflagwillbeignoredif{@link#FLAG_ACTIVITY_CLEAR_TOP}isalso*specified.*/publicstaticfinalintFLAG_ACTIVITY_REORDER_TO_FRONT=0X00020000;/***IfsetinanIntentpassedto{@linkContext#startActivityContext.startActivity()},*thisflagwillpreventthesystemfromapplyinganactivitytransition*animationtogotothenextactivitystate.Thisdoesn'tmeanan*animationwillneverrun--ifanotheractivitychangehappensthatdoesn't*specifythisflagbeforetheactivitystartedhereisdisplayed,then*thattransitionwillbeused.Thisflagcanbeputtogooduse*whenyouaregoingtodoaseriesofactivityoperationsbutthe*animationseenbytheusershouldn'tbedrivenbythefirstactivity*changebutratheralaterone.*/publicstaticfinalintFLAG_ACTIVITY_NO_ANIMATION=0X00010000;/***IfsetinanIntentpassedto{@linkContext#startActivityContext.startActivity()},*thisflagwillcauseanyexistingtaskthatwouldbeassociatedwiththe*activitytobeclearedbeforetheactivityisstarted.Thatis,theactivity*becomesthenewrootofanotherwiseemptytask,andanyoldactivities*arefinished.Thiscanonlybeusedinconjunctionwith{@link#FLAG_ACTIVITY_NEW_TASK}.*/publicstaticfinalintFLAG_ACTIVITY_CLEAR_TASK=0X00008000;/***IfsetinanIntentpassedto{@linkContext#startActivityContext.startActivity()},*thisflagwillcauseanewlylaunchingtasktobeplacedontopofthecurrent*homeactivitytask(ifthereisone).Thatis,pressingbackfromthetask*willalwaysreturntheusertohomeevenifthatwasnotthelastactivitythey*saw.Thiscanonlybeusedinconjunctionwith{@link#FLAG_ACTIVITY_NEW_TASK}.*/publicstaticfinalintFLAG_ACTIVITY_TASK_ON_HOME=0X00004000;/***Ifset,whensendingabroadcastonlyregisteredreceiverswillbe*called--noBroadcastReceivercomponentswillbelaunched.*/publicstaticfinalintFLAG_RECEIVER_REGISTERED_ONLY=0x40000000;/***Ifset,whensendingabroadcastthenewbroadcastwillreplace*anyexistingpendingbroadcastthatmatchesit.Matchingisdefined*by{@linkIntent#filterEquals(Intent)Intent.filterEquals}returning*truefortheintentsofthetwobroadcasts.Whenamatchisfound,*thenewbroadcast(andreceiversassociatedwithit)willreplacethe*existingoneinthependingbroadcastlist,remainingatthesame*positioninthelist.** Thisflagismosttypicallyusedwithstickybroadcasts,which*onlycareaboutdeliveringthemostrecentvaluesofthebroadcast*totheirreceivers.*/publicstaticfinalintFLAG_RECEIVER_REPLACE_PENDING=0x20000000;/***Ifset,whensendingabroadcasttherecipientisallowedtorunat*foregroundpriority,withashortertimeoutinterval.Duringnormal*broadcaststhereceiversarenotautomaticallyhoistedoutofthe*backgroundpriorityclass.*/publicstaticfinalintFLAG_RECEIVER_FOREGROUND=0x10000000;/***Ifset,whensendingabroadcastbeforeboothascompletedonly*registeredreceiverswillbecalled--noBroadcastReceivercomponents*willbelaunched.Stickyintentstatewillberecordedproperlyeven*ifnoreceiverswindupbeingcalled.If{@link#FLAG_RECEIVER_REGISTERED_ONLY}*isspecifiedinthebroadcastintent,thisflagisunnecessary.** Thisflagisonlyforusebysystemsevicesasaconvenienceto*avoidhavingtoimplementamorecomplexmechanismarounddetection*ofbootcompletion.**@hide*/publicstaticfinalintFLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT=0x08000000;/***Setwhenthisbroadcastisforabootupgrade,aspecialmodethat*allowsthebroadcasttobesentbeforethesystemisreadyandlaunches*theappprocesswithnoprovidersrunninginit.*@hide*/publicstaticfinalintFLAG_RECEIVER_BOOT_UPGRADE=0x04000000;/***@hideFlagsthatcan'tbechangedwithPendingIntent.*/publicstaticfinalintIMMUTABLE_FLAGS=FLAG_GRANT_READ_URI_PERMISSION|FLAG_GRANT_WRITE_URI_PERMISSION;//---------------------------------------------------------------------//---------------------------------------------------------------------//toUri()andparseUri()options./***Flagforusewith{@link#toUri}and{@link#parseUri}:theURIstring*alwayshasthe"intent:"scheme.Thissyntaxcanbeusedwhenyouwant*tolaterdisambiguatebetweenURIsthatareintendedtodescribean*Intentvs.allothersthatshouldbetreatedasrawURIs.Whenused*with{@link#parseUri},anyotherschemewillresultinageneric*VIEWactionforthatrawURI.*/publicstaticfinalintURI_INTENT_SCHEME=1<<0;//---------------------------------------------------------------------privateStringmAction;privateUrimData;privateStringmType;privateStringmPackage;privateComponentNamemComponent;privateintmFlags;privateHashSet Note:schemeandhostnamematchingintheAndroidframeworkis*case-sensitive,unliketheformalRFC.Asaresult,*youshouldalwaysensurethatyouwriteyourUriwiththeseelements*usinglowercaseletters,andnormalizeanyUrisyoureceivefrom*outsideofAndroidtoensuretheschemeandhostislowercase. Note:schemeandhostnamematchingintheAndroidframeworkis*case-sensitive,unliketheformalRFC.Asaresult,*youshouldalwaysensurethatyouwriteyourUriwiththeseelements*usinglowercaseletters,andnormalizeanyUrisyoureceivefrom*outsideofAndroidtoensuretheschemeandhostislowercase. ThereturnedIntenthasthegivenActivitycomponentasitsexplicit*component,{@link#ACTION_MAIN}asitsaction,andincludesthe*category{@link#CATEGORY_LAUNCHER}.Thisdoesnothave*{@link#FLAG_ACTIVITY_NEW_TASK}set,thoughtypicallyyouwillwant*todothatthrough{@link#addFlags(int)}onthereturnedIntent.**@parammainActivityThemainactivitycomponentthatthisIntentwill*launch.*@returnReturnsanewlycreatedIntentthatcanbeusedtolaunchthe*activityasamainapplicationentry.**@see#setClass*@see#setComponent*/publicstaticIntentmakeMainActivity(ComponentNamemainActivity){Intentintent=newIntent(ACTION_MAIN);intent.setComponent(mainActivity);intent.addCategory(CATEGORY_LAUNCHER);returnintent;}/***MakeanIntentforthemainactivityofanapplication,without*specifyingaspecificactivitytorunbutgivingaselectortofind*theactivity.ThisresultsinafinalIntentthatisstructured*thesameaswhentheapplicationislaunchedfrom*Home.Foranythingelsethatwantstolaunchanapplicationinthe*sameway,itisimportantthattheyuseanIntentstructuredthesame*way,andcanusethisfunctiontoensurethisisthecase.** ThereturnedIntenthas{@link#ACTION_MAIN}asitsaction,andincludesthe*category{@link#CATEGORY_LAUNCHER}.Thisdoesnothave*{@link#FLAG_ACTIVITY_NEW_TASK}set,thoughtypicallyyouwillwant*todothatthrough{@link#addFlags(int)}onthereturnedIntent.**@paramselectorActionTheactionnameoftheIntent'sselector.*@paramselectorCategoryThenameofacategorytoaddtotheIntent's*selector.*@returnReturnsanewlycreatedIntentthatcanbeusedtolaunchthe*activityasamainapplicationentry.**@see#setSelector(Intent)*/publicstaticIntentmakeMainSelectorActivity(StringselectorAction,StringselectorCategory){Intentintent=newIntent(ACTION_MAIN);intent.addCategory(CATEGORY_LAUNCHER);Intentselector=newIntent();selector.setAction(selectorAction);selector.addCategory(selectorCategory);intent.setSelector(selector);returnintent;}/***MakeanIntentthatcanbeusedtore-launchanapplication'stask*initsbasestate.Thisislike{@link#makeMainActivity(ComponentName)},*butalsosetstheflags{@link#FLAG_ACTIVITY_NEW_TASK}and*{@link#FLAG_ACTIVITY_CLEAR_TASK}.**@parammainActivityTheactivitycomponentthatistherootofthe*task;thisistheactivitythathasbeenpublishedintheapplication's*manifestasthemainlaunchericon.**@returnReturnsanewlycreatedIntentthatcanbeusedtorelaunchthe*activity'staskinitsrootstate.*/publicstaticIntentmakeRestartActivityTask(ComponentNamemainActivity){Intentintent=makeMainActivity(mainActivity);intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK);returnintent;}/***Call{@link#parseUri}with0flags.*@deprecatedUse{@link#parseUri}instead.*/@DeprecatedpublicstaticIntentgetIntent(Stringuri)throwsURISyntaxException{returnparseUri(uri,0);}/***CreateanintentfromaURI.ThisURImayencodetheaction,*category,andotherintentfields,ifitwasreturnedby*{@link#toUri}.IftheIntentwasnotgeneratebytoUri(),itsdata*willbetheentireURIanditsactionwillbeACTION_VIEW.** TheURIgivenheremustnotberelative--thatis,itmustinclude*theschemeandfullpath.**@paramuriTheURItoturnintoanIntent.*@paramflagsAdditionalprocessingflags.Either0or*{@link#URI_INTENT_SCHEME}.**@returnIntentThenewlycreatedIntentobject.**@throwsURISyntaxExceptionThrowsURISyntaxErrorifthebasicURIsyntax*itbad(asparsedbytheUriclass)ortheIntentdatawithinthe*URIisinvalid.**@see#toUri*/publicstaticIntentparseUri(Stringuri,intflags)throwsURISyntaxException{inti=0;try{//Validateintentschemeforifrequested.if((flags&URI_INTENT_SCHEME)!=0){if(!uri.startsWith("intent:")){Intentintent=newIntent(ACTION_VIEW);try{intent.setData(Uri.parse(uri));}catch(IllegalArgumentExceptione){thrownewURISyntaxException(uri,e.getMessage());}returnintent;}}//simplecasei=uri.lastIndexOf("#");if(i==-1)returnnewIntent(ACTION_VIEW,Uri.parse(uri));//oldformatIntentURIif(!uri.startsWith("#Intent;",i))returngetIntentOld(uri);//newformatIntentintent=newIntent(ACTION_VIEW);IntentbaseIntent=intent;//fetchdatapart,ifpresentStringdata=i>=0?uri.substring(0,i):null;Stringscheme=null;i+="#Intent;".length();//loopovercontentsofIntent,allname=value;while(!uri.startsWith("end",i)){inteq=uri.indexOf('=',i);if(eq<0)eq=i-1;intsemi=uri.indexOf(';',i);Stringvalue=eq ThisisthesameascallinggetData().getScheme()(andcheckingfor*nulldata).**@returnTheschemeofthisintent.**@see#getData*/publicStringgetScheme(){returnmData!=null?mData.getScheme():null;}/***RetrieveanyexplicitMIMEtypeincludedintheintent.Thisisusually*null,asthetypeisdeterminedbytheintentdata.**@returnIfatypewasmanuallyset,itisreturned;elsenullis*returned.**@see#resolveType(ContentResolver)*@see#setType*/publicStringgetType(){returnmType;}/***ReturntheMIMEdatatypeofthisintent.Ifthetypefieldis*explicitlyset,thatissimplyreturned.Otherwise,ifthedataisset,*thetypeofthatdataisreturned.Ifneitherfieldsareset,anullis*returned.**@returnTheMIMEtypeofthisintent.**@see#getType*@see#resolveType(ContentResolver)*/publicStringresolveType(Contextcontext){returnresolveType(context.getContentResolver());}/***ReturntheMIMEdatatypeofthisintent.Ifthetypefieldis*explicitlyset,thatissimplyreturned.Otherwise,ifthedataisset,*thetypeofthatdataisreturned.Ifneitherfieldsareset,anullis*returned.**@paramresolverAContentResolverthatcanbeusedtodeterminetheMIME*typeoftheintent'sdata.**@returnTheMIMEtypeofthisintent.**@see#getType*@see#resolveType(Context)*/publicStringresolveType(ContentResolverresolver){if(mType!=null){returnmType;}if(mData!=null){if("content".equals(mData.getScheme())){returnresolver.getType(mData);}}returnnull;}/***ReturntheMIMEdatatypeofthisintent,onlyifitwillbeneededfor*intentresolution.Thisisnotgenerallyusefulforapplicationcode;*itisusedbytheframeworksforcommunicatingwithback-endsystem*services.**@paramresolverAContentResolverthatcanbeusedtodeterminetheMIME*typeoftheintent'sdata.**@returnTheMIMEtypeofthisintent,ornullifitisunknownornot*needed.*/publicStringresolveTypeIfNeeded(ContentResolverresolver){if(mComponent!=null){returnmType;}returnresolveType(resolver);}/***Checkifacategoryexistsintheintent.**@paramcategoryThecategorytocheck.**@returnbooleanTrueiftheintentcontainsthecategory,elsefalse.**@see#getCategories*@see#addCategory*/publicbooleanhasCategory(Stringcategory){returnmCategories!=null&&mCategories.contains(category);}/***Returnthesetofallcategoriesintheintent.Iftherearenocategories,*returnsNULL.**@returnThesetofcategoriesyoucanexamine.Donotmodify!**@see#hasCategory*@see#addCategory*/publicSet If{@link#getComponent}returnsanexplicitclass,thatisreturned*withoutanyfurtherconsideration.** Theactivitymusthandlethe{@linkIntent#CATEGORY_DEFAULT}Intent*categorytobeconsidered.** If{@link#getAction}isnon-NULL,theactivitymusthandlethis*action.** If{@link#resolveType}returnsnon-NULL,theactivitymusthandle*thistype.** If{@link#addCategory}hasaddedanycategories,theactivitymust*handleALLofthecategoriesspecified.** If{@link#getPackage}isnon-NULL,onlyactivitycomponentsin*thatapplicationpackagewillbeconsidered.** Iftherearenoactivitiesthatsatisfyalloftheseconditions,a*nullstringisreturned.** Ifmultipleactivitiesarefoundtosatisfytheintent,theonewith*thehighestprioritywillbeused.Iftherearemultipleactivities*withthesamepriority,thesystemwilleitherpickthebestactivity*basedonuserpreference,orresolvetoasystemclassthatwillallow*theusertopickanactivityandforwardfromthere.** Thismethodisimplementedsimplybycalling*{@linkPackageManager#resolveActivity}withthe"defaultOnly"parameter*true. ThisAPIiscalledforyouaspartofstartinganactivityfroman*intent.Youdonotnormallyneedtocallityourself. Note:schemematchingintheAndroidframeworkis*case-sensitive,unliketheformalRFC.Asaresult,*youshouldalwayswriteyourUriwithalowercasescheme,*oruse{@linkUri#normalize}or*{@link#setDataAndNormalize}*toensurethattheschemeisconvertedtolowercase.**@paramdataTheUriofthedatathisintentisnowtargeting.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#getData*@see#setDataAndNormalize*@seeandroid.net.Intent#normalize*/publicIntentsetData(Uridata){mData=data;mType=null;returnthis;}/***Normalizeandsetthedatathisintentisoperatingon.** Thismethodautomaticallyclearsanytypethatwas*previouslyset(forexample,by{@link#setType}).** ThedataUriisnormalizedusing*{@linkandroid.net.Uri#normalize}beforeitisset,*soreallythisisjustaconveniencemethodfor* Thisisusedtocreateintentsthatonlyspecifyatypeandnotdata,*forexampletoindicatethetypeofdatatoreturn.** Thismethodautomaticallyclearsanydatathatwas*previouslyset(forexampleby{@link#setData}).** Note:MIMEtypematchingintheAndroidframeworkis*case-sensitive,unlikeformalRFCMIMEtypes.Asaresult,*youshouldalwayswriteyourMIMEtypeswithlowercaseletters,*oruse{@link#normalizeMimeType}or{@link#setTypeAndNormalize}*toensurethatitisconvertedtolowercase.**@paramtypeTheMIMEtypeofthedatabeinghandledbythisintent.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#getType*@see#setTypeAndNormalize*@see#setDataAndType*@see#normalizeMimeType*/publicIntentsetType(Stringtype){mData=null;mType=type;returnthis;}/***NormalizeandsetanexplicitMIMEdatatype.** Thisisusedtocreateintentsthatonlyspecifyatypeandnotdata,*forexampletoindicatethetypeofdatatoreturn.** Thismethodautomaticallyclearsanydatathatwas*previouslyset(forexampleby{@link#setData}).** TheMIMEtypeisnormalizedusing*{@link#normalizeMimeType}beforeitisset,*soreallythisisjustaconveniencemethodfor* Note:MIMEtypeandUrischemematchinginthe*Androidframeworkiscase-sensitive,unliketheformalRFCdefinitions.*Asaresult,youshouldalwayswritetheseelementswithlowercaseletters,*oruse{@link#normalizeMimeType}or{@linkandroid.net.Uri#normalize}or*{@link#setDataAndTypeAndNormalize}*toensurethattheyareconvertedtolowercase.**@paramdataTheUriofthedatathisintentisnowtargeting.*@paramtypeTheMIMEtypeofthedatabeinghandledbythisintent.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#setType*@see#setData*@see#normalizeMimeType*@seeandroid.net.Uri#normalize*@see#setDataAndTypeAndNormalize*/publicIntentsetDataAndType(Uridata,Stringtype){mData=data;mType=type;returnthis;}/***(Usuallyoptional)NormalizeandsetboththedataUriandanexplicit*MIMEdatatype.Thismethodshouldveryrarelybeused--itallowsyou*tooverridetheMIMEtypethatwouldordinarilybeinferredfromthe*datawithyourowntypegivenhere.** ThedataUriandtheMIMEtypearenormalizeusing*{@linkandroid.net.Uri#normalize}and{@link#normalizeMimeType}*beforetheyareset,soreallythisisjustaconveniencemethodfor* Anexampleofwherethismaybeusediswiththingslike*{@link#CATEGORY_APP_BROWSER}.Thiscategoryallowsyoutobuildan*IntentthatwilllaunchtheBrowserapplication.However,thecorrect*mainentrypointofanapplicationisactually{@link#ACTION_MAIN}*{@link#CATEGORY_LAUNCHER}with{@link#setComponent(ComponentName)}*usedtospecifytheactualActivitytolaunch.Ifyoulaunchthebrowser*withsomethingdifferent,undesiredbehaviormayhappeniftheuserhas*previouslyorlaterlaunchesitthenormalway,sincetheydonotmatch.*Instead,youcanbuildanIntentwiththeMAINaction(butnoComponentName*yetspecified)andsetaselectorwith{@link#ACTION_MAIN}and*{@link#CATEGORY_APP_BROWSER}topointitspecificallytothebrowseractivity.** Settingaselectordoesnotimpactthebehaviorof*{@link#filterEquals(Intent)}and{@link#filterHashCode()}.Thisispartofthe*desiredbehaviorofaselector--itdoesnotimpactthebasemeaning*oftheIntent,justwhatkindsofthingswillbematchedagainstit*whendeterminingwhocanhandleit. Youcannotusebothaselectorand{@link#setPackage(String)}on*thesamebaseIntent. TheClipDatainanintentisnotusedforIntentmatchingorother*suchoperations.Semanticallyitislikeextras,usedtotransmit*additionaldatawiththeIntent.Themainfeatureofusingthisover*theextrasfordataisthat{@link#FLAG_GRANT_READ_URI_PERMISSION}*and{@link#FLAG_GRANT_WRITE_URI_PERMISSION}willoperateonanyURI*itemsincludedintheclipdata.Thisisuseful,inparticular,if*youwanttotransmitanIntentcontainingmultiple IftheClipDatacontainsitemsthatarethemselvesIntents,any*grantflagsinthoseIntentswillbeignored.Onlythetop-levelflags*ofthemainIntentarerespected,andwillbeappliedtoallUrior*Intentitemsintheclip(orsub-itemsoftheclip).** TheMIMEtype,label,andiconintheClipDataobjectarenot*directlyusedbyIntent.Applicationsshouldgenerallyrelyonthe*MIMEtypeoftheIntentitself,notwhatitmayfindintheClipData.*AcommonpracticeistoconstructaClipDataforusewithanIntent*withaMIMEtypeof"*\/*".**@paramclipThenewcliptoset.Maybenulltoclearthecurrentclip.*/publicvoidsetClipData(ClipDataclip){mClipData=clip;}/***Addextendeddatatotheintent.Thenamemustincludeapackage*prefix,forexampletheappcom.android.contactswouldusenames*like"com.android.contacts.ShowAll".**@paramnameThenameoftheextradata,withpackageprefix.*@paramvalueThebooleandatavalue.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#putExtras*@see#removeExtra*@see#getBooleanExtra(String,boolean)*/publicIntentputExtra(Stringname,booleanvalue){if(mExtras==null){mExtras=newBundle();}mExtras.putBoolean(name,value);returnthis;}/***Addextendeddatatotheintent.Thenamemustincludeapackage*prefix,forexampletheappcom.android.contactswouldusenames*like"com.android.contacts.ShowAll".**@paramnameThenameoftheextradata,withpackageprefix.*@paramvalueThebytedatavalue.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#putExtras*@see#removeExtra*@see#getByteExtra(String,byte)*/publicIntentputExtra(Stringname,bytevalue){if(mExtras==null){mExtras=newBundle();}mExtras.putByte(name,value);returnthis;}/***Addextendeddatatotheintent.Thenamemustincludeapackage*prefix,forexampletheappcom.android.contactswouldusenames*like"com.android.contacts.ShowAll".**@paramnameThenameoftheextradata,withpackageprefix.*@paramvalueThechardatavalue.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#putExtras*@see#removeExtra*@see#getCharExtra(String,char)*/publicIntentputExtra(Stringname,charvalue){if(mExtras==null){mExtras=newBundle();}mExtras.putChar(name,value);returnthis;}/***Addextendeddatatotheintent.Thenamemustincludeapackage*prefix,forexampletheappcom.android.contactswouldusenames*like"com.android.contacts.ShowAll".**@paramnameThenameoftheextradata,withpackageprefix.*@paramvalueTheshortdatavalue.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#putExtras*@see#removeExtra*@see#getShortExtra(String,short)*/publicIntentputExtra(Stringname,shortvalue){if(mExtras==null){mExtras=newBundle();}mExtras.putShort(name,value);returnthis;}/***Addextendeddatatotheintent.Thenamemustincludeapackage*prefix,forexampletheappcom.android.contactswouldusenames*like"com.android.contacts.ShowAll".**@paramnameThenameoftheextradata,withpackageprefix.*@paramvalueTheintegerdatavalue.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#putExtras*@see#removeExtra*@see#getIntExtra(String,int)*/publicIntentputExtra(Stringname,intvalue){if(mExtras==null){mExtras=newBundle();}mExtras.putInt(name,value);returnthis;}/***Addextendeddatatotheintent.Thenamemustincludeapackage*prefix,forexampletheappcom.android.contactswouldusenames*like"com.android.contacts.ShowAll".**@paramnameThenameoftheextradata,withpackageprefix.*@paramvalueThelongdatavalue.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#putExtras*@see#removeExtra*@see#getLongExtra(String,long)*/publicIntentputExtra(Stringname,longvalue){if(mExtras==null){mExtras=newBundle();}mExtras.putLong(name,value);returnthis;}/***Addextendeddatatotheintent.Thenamemustincludeapackage*prefix,forexampletheappcom.android.contactswouldusenames*like"com.android.contacts.ShowAll".**@paramnameThenameoftheextradata,withpackageprefix.*@paramvalueThefloatdatavalue.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#putExtras*@see#removeExtra*@see#getFloatExtra(String,float)*/publicIntentputExtra(Stringname,floatvalue){if(mExtras==null){mExtras=newBundle();}mExtras.putFloat(name,value);returnthis;}/***Addextendeddatatotheintent.Thenamemustincludeapackage*prefix,forexampletheappcom.android.contactswouldusenames*like"com.android.contacts.ShowAll".**@paramnameThenameoftheextradata,withpackageprefix.*@paramvalueThedoubledatavalue.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#putExtras*@see#removeExtra*@see#getDoubleExtra(String,double)*/publicIntentputExtra(Stringname,doublevalue){if(mExtras==null){mExtras=newBundle();}mExtras.putDouble(name,value);returnthis;}/***Addextendeddatatotheintent.Thenamemustincludeapackage*prefix,forexampletheappcom.android.contactswouldusenames*like"com.android.contacts.ShowAll".**@paramnameThenameoftheextradata,withpackageprefix.*@paramvalueTheStringdatavalue.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#putExtras*@see#removeExtra*@see#getStringExtra(String)*/publicIntentputExtra(Stringname,Stringvalue){if(mExtras==null){mExtras=newBundle();}mExtras.putString(name,value);returnthis;}/***Addextendeddatatotheintent.Thenamemustincludeapackage*prefix,forexampletheappcom.android.contactswouldusenames*like"com.android.contacts.ShowAll".**@paramnameThenameoftheextradata,withpackageprefix.*@paramvalueTheCharSequencedatavalue.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#putExtras*@see#removeExtra*@see#getCharSequenceExtra(String)*/publicIntentputExtra(Stringname,CharSequencevalue){if(mExtras==null){mExtras=newBundle();}mExtras.putCharSequence(name,value);returnthis;}/***Addextendeddatatotheintent.Thenamemustincludeapackage*prefix,forexampletheappcom.android.contactswouldusenames*like"com.android.contacts.ShowAll".**@paramnameThenameoftheextradata,withpackageprefix.*@paramvalueTheParcelabledatavalue.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#putExtras*@see#removeExtra*@see#getParcelableExtra(String)*/publicIntentputExtra(Stringname,Parcelablevalue){if(mExtras==null){mExtras=newBundle();}mExtras.putParcelable(name,value);returnthis;}/***Addextendeddatatotheintent.Thenamemustincludeapackage*prefix,forexampletheappcom.android.contactswouldusenames*like"com.android.contacts.ShowAll".**@paramnameThenameoftheextradata,withpackageprefix.*@paramvalueTheParcelable[]datavalue.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#putExtras*@see#removeExtra*@see#getParcelableArrayExtra(String)*/publicIntentputExtra(Stringname,Parcelable[]value){if(mExtras==null){mExtras=newBundle();}mExtras.putParcelableArray(name,value);returnthis;}/***Addextendeddatatotheintent.Thenamemustincludeapackage*prefix,forexampletheappcom.android.contactswouldusenames*like"com.android.contacts.ShowAll".**@paramnameThenameoftheextradata,withpackageprefix.*@paramvalueTheArrayList Seethe* Inaddition,youcanusethe{@link#FILL_IN_ACTION},*{@link#FILL_IN_DATA},{@link#FILL_IN_CATEGORIES},{@link#FILL_IN_PACKAGE},*{@link#FILL_IN_COMPONENT},{@link#FILL_IN_SOURCE_BOUNDS},*{@link#FILL_IN_SELECTOR},and{@link#FILL_IN_CLIP_DATA}tooverride*therestrictionwherethecorrespondingfieldwillnotbereplacedif*itisalreadyset.** Note:Thecomponentfieldwillonlybecopiedif{@link#FILL_IN_COMPONENT}*isexplicitlyspecified.Theselectorwillonlybecopiedif*{@link#FILL_IN_SELECTOR}isexplicitlyspecified.** Forexample,considerIntentAwith{data="foo",categories="bar"}*andIntentBwith{action="gotit",data-type="some/thing",*categories="one","two"}.** CallingA.fillIn(B,Intent.FILL_IN_DATA)willresultinAnow*containing:{action="gotit",data-type="some/thing",*categories="bar"}.**@paramotherAnotherIntentwhosevaluesaretobeusedtofillin*thecurrentone.*@paramflagsOptionstocontrolwhichfieldscanbefilledin.**@returnReturnsabitmaskof{@link#FILL_IN_ACTION},*{@link#FILL_IN_DATA},{@link#FILL_IN_CATEGORIES},{@link#FILL_IN_PACKAGE},*{@link#FILL_IN_COMPONENT},{@link#FILL_IN_SOURCE_BOUNDS},and*{@link#FILL_IN_SELECTOR}indicatingwhichfieldswerechanged.*/publicintfillIn(Intentother,intflags){intchanges=0;if(other.mAction!=null&&(mAction==null||(flags&FILL_IN_ACTION)!=0)){mAction=other.mAction;changes|=FILL_IN_ACTION;}if((other.mData!=null||other.mType!=null)&&((mData==null&&mType==null)||(flags&FILL_IN_DATA)!=0)){mData=other.mData;mType=other.mType;changes|=FILL_IN_DATA;}if(other.mCategories!=null&&(mCategories==null||(flags&FILL_IN_CATEGORIES)!=0)){if(other.mCategories!=null){mCategories=newHashSet YoucanconvertthereturnedstringbacktoanIntentwith*{@link#getIntent}.**@paramflagsAdditionaloperatingflags.Either0or*{@link#URI_INTENT_SCHEME}.**@returnReturnsaURIencodingURIstringdescribingtheentirecontents*oftheIntent.*/publicStringtoUri(intflags){StringBuilderuri=newStringBuilder(128);Stringscheme=null;if(mData!=null){Stringdata=mData.toString();if((flags&URI_INTENT_SCHEME)!=0){finalintN=data.length();for(inti=0;i AnormalizedMIMEtypehaswhite-spacetrimmed,*content-typeparametersremoved,andislower-case.*ThisalignsthetypewithAndroidbestpracticesfor*intentfiltering.** Forexample,"text/plain;charset=utf-8"becomes"text/plain".*"text/x-vCard"becomes"text/x-vcard".** AllMIMEtypesreceivedfromoutsideAndroid(suchasuserinput,*orexternalsourceslikeBluetooth,NFC,ortheInternet)should*benormalizedbeforetheyareusedtocreateanIntent.**@paramtypeMIMEdatatypetonormalize*@returnnormalizedMIMEdatatype,ornulliftheinputwasnull*@see{@link#setType}*@see{@link#setTypeAndNormalize}*/publicstaticStringnormalizeMimeType(Stringtype){if(type==null){returnnull;}type=type.trim().toLowerCase(Locale.US);finalintsemicolonIndex=type.indexOf(';');if(semicolonIndex!=-1){type=type.substring(0,semicolonIndex);}returntype;}/***Migrateany{@link#EXTRA_STREAM}in{@link#ACTION_SEND}and*{@link#ACTION_SEND_MULTIPLE}to{@linkClipData}.**@hide*/publicvoidmigrateExtraStreamToClipData(){//Refusetotouchifextrasalreadyparcelledif(mExtras!=null&&mExtras.isParcelled())return;//BailwhensomeonealreadygaveusClipDataif(getClipData()!=null)return;finalStringaction=getAction();if(ACTION_SEND.equals(action)){finalUristream=getParcelableExtra(EXTRA_STREAM);if(stream!=null){finalClipDataclipData=newClipData(null,newString[]{getType()},newClipData.Item(stream));setClipData(clipData);addFlags(FLAG_GRANT_READ_URI_PERMISSION);}}elseif(ACTION_SEND_MULTIPLE.equals(action)){finalArrayList*
***
***
***
***
***
***
***
***
***
***
***
***
**Thisintentwillbesentatboot(ifthecountisnon-zero)andwhenthe*datasetchanges.Itispossibleforthedatasettochangewithoutthe*countchanging(forexample,ifanewunreadmessagearrivesinthesame*syncoperationinwhichamessageisarchived).Thephoneshouldstill*ring/vibrate/etcasnormalinthiscase.*/@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)publicstaticfinalStringACTION_PROVIDER_CHANGED="android.intent.action.PROVIDER_CHANGED";/***BroadcastAction:WiredHeadsetpluggedinorunplugged.***
**/@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)publicstaticfinalStringACTION_HEADSET_PLUG="android.intent.action.HEADSET_PLUG";/***BroadcastAction:Ananalogaudiospeaker/headsetpluggedinorunplugged.***
**@hide*/@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)publicstaticfinalStringACTION_USB_ANLG_HEADSET_PLUG="android.intent.action.USB_ANLG_HEADSET_PLUG";/***BroadcastAction:Adigitalaudiospeaker/headsetpluggedinorunplugged.***
**@hide*/@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)publicstaticfinalStringACTION_USB_DGTL_HEADSET_PLUG="android.intent.action.USB_DGTL_HEADSET_PLUG";/***BroadcastAction:AHMDIcablewaspluggedorunplugged***
**@hide*/@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)publicstaticfinalStringACTION_HDMI_AUDIO_PLUG="android.intent.action.HDMI_AUDIO_PLUG";/****
***
*null
,nocallwillbeplaced.*
**setData(data.normalize())*
**@paramdataTheUriofthedatathisintentisnowtargeting.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#getData*@see#setType*@seeandroid.net.Uri#normalize*/publicIntentsetDataAndNormalize(Uridata){returnsetData(data.normalize());}/***SetanexplicitMIMEdatatype.***setType(Intent.normalizeMimeType(type))*
**@paramtypeTheMIMEtypeofthedatabeinghandledbythisintent.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#getType*@see#setData*@see#normalizeMimeType*/publicIntentsetTypeAndNormalize(Stringtype){returnsetType(normalizeMimeType(type));}/***(Usuallyoptional)Setthedatafortheintentalongwithanexplicit*MIMEdatatype.Thismethodshouldveryrarelybeused--itallowsyou*tooverridetheMIMEtypethatwouldordinarilybeinferredfromthe*datawithyourowntypegivenhere.***setDataAndType(data.normalize(),Intent.normalizeMimeType(type))*
**@paramdataTheUriofthedatathisintentisnowtargeting.*@paramtypeTheMIMEtypeofthedatabeinghandledbythisintent.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#setType*@see#setData*@see#setDataAndType*@see#normalizeMimeType*@seeandroid.net.Uri#normalize*/publicIntentsetDataAndTypeAndNormalize(Uridata,Stringtype){returnsetDataAndType(data.normalize(),normalizeMimeType(type));}/***Addanewcategorytotheintent.Categoriesprovideadditionaldetail*abouttheactiontheintentperforms.Whenresolvinganintent,only*activitiesthatprovidealloftherequestedcategorieswillbe*used.**@paramcategoryThedesiredcategory.Thiscanbeeitheroneofthe*predefinedIntentcategories,oracustomcategoryinyourown*namespace.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#hasCategory*@see#removeCategory*/publicIntentaddCategory(Stringcategory){if(mCategories==null){mCategories=newHashSetcontent:
*URIsforwhichtherecipientmaynothaveglobalpermissiontoaccessthe*contentprovider.**setClassName(context,cls.getName())
.**@returnReturnsthesameIntentobject,forchainingmultiplecalls*intoasinglestatement.**@see#setComponent*/publicIntentsetClass(ContextpackageContext,Class>cls){mComponent=newComponentName(packageContext,cls);returnthis;}/***Settheboundsofthesenderofthisintent,inscreencoordinates.Thiscanbe*usedasahinttothereceiverforanimationsandthelike.Nullmeansthatthere*isnosourcebounds.*/publicvoidsetSourceBounds(Rectr){if(r!=null){mSourceBounds=newRect(r);}else{mSourceBounds=null;}}/***Usewith{@link#fillIn}toallowthecurrentactionvaluetobe*overwritten,evenifitisalreadyset.*/publicstaticfinalintFILL_IN_ACTION=1<<0;/***Usewith{@link#fillIn}toallowthecurrentdataortypevalue*overwritten,evenifitisalreadyset.*/publicstaticfinalintFILL_IN_DATA=1<<1;/***Usewith{@link#fillIn}toallowthecurrentcategoriestobe*overwritten,eveniftheyarealreadyset.*/publicstaticfinalintFILL_IN_CATEGORIES=1<<2;/***Usewith{@link#fillIn}toallowthecurrentcomponentvaluetobe*overwritten,evenifitisalreadyset.*/publicstaticfinalintFILL_IN_COMPONENT=1<<3;/***Usewith{@link#fillIn}toallowthecurrentpackagevaluetobe*overwritten,evenifitisalreadyset.*/publicstaticfinalintFILL_IN_PACKAGE=1<<4;/***Usewith{@link#fillIn}toallowthecurrentboundsrectangletobe*overwritten,evenifitisalreadyset.*/publicstaticfinalintFILL_IN_SOURCE_BOUNDS=1<<5;/***Usewith{@link#fillIn}toallowthecurrentselectortobe*overwritten,evenifitisalreadyset.*/publicstaticfinalintFILL_IN_SELECTOR=1<<6;/***Usewith{@link#fillIn}toallowthecurrentClipDatatobe*overwritten,evenifitisalreadyset.*/publicstaticfinalintFILL_IN_CLIP_DATA=1<<7;/***Copythecontentsofotherintothisobject,butonly*wherefieldsarenotdefinedbythisobject.Forpurposesofafield*beingdefined,thefollowingpiecesofdataintheIntentare*consideredtobeseparatefields:***
**
延伸文章資訊
- 1core/java/android/content/Intent.java - platform/frameworks/base
* defined in the Intent class, but applications can also define their own. * These strings use ja...
- 2透過Intent 切換Activity 並利用Bundle 傳送參數
Intent 照字面翻譯,有『意圖』的意思,我們可以把它想像為這個應用程式的意圖,而要完成這個意圖,我們通常需要為其附帶一個『動作』,也就是Action,像是撥打電話時 ...
- 3[Android自學筆記]14. Intent用法-範例練習 - Medium
Intent intent = new Intent(MainActivity.this, Main2Activity.class); startActivity(intent);. 表示目前在...
- 4【 Android 教學中文開放式課程】Intent 跳頁&傳遞資料
HKT 線上教室. Swift / iOS / Flutter / Android / Kotlin / Java 手機APP 應用程式開發教學 ...
- 5使用Intent轉換Activity並傳遞資料,什麼是Intent意圖?
Intent intent = new Intent(this, ResultActivity.class); intent.putExtra("BMI_EXTRA", bmi); startA...