Android Intent

Intent P'J WtfiJâ Android t.itttt* Intent f, ft

-»CitfHSiJ / Intent, &^SHHÎK£ Intent Milltfl, il

*t Intent*

KftmRR&mmiimmmmMm. Android r#mmr-mm, &

9.1.1 Intent SfiHj

Intent ft Android mi 'I ' £+11 ^ffifi- M, il M Intent ffiift 0 ft Android M'fT/j

API Intent ièiÎfiPSi An intent is an abstract description of an operation to be performed., t Intent J4»WEJIT 3

• iffiii startActivity //ifc^féfâill—^SrftJ Activity:

• Mil" broadcast Intent UL ©J "J W # — Is* Intent £ tT: fnJ *t S ^ Intent l>& ® fftl BroadcastReceivero

• M H startService ( Intent) "Jc bindService ( Intent, ServiceConnection, int) ^iU/jSnfft Service mr^LKo

XT-r-fS (Broadcast) *II1B£ (Service) W Si ft ff I & /A Jn& ftfj «S iit ÎT W- »I W . ¿MA ftiijiift* fî - Rnf'fMil startActivity ÏÀ/j -'HSrM Activity.

Intent "t/SJIJ wVt'M ft'h Activity, ÎtPSftffJtt! Activity ii.

« 9 $ a* fatf) "iftffl" -Intent in Broadcast

M& Intent «1 f. ftS/t^'Vl'ftll t Activity ififlf«in^*ftJ startActivity //fcfc, Jj ffi Intent iWilli KW^:

startActivity(mylntent) ;

Intent i' ^ Activity, ¡SMiiRti^Ti^fe Activity ffiftJtft^J

Bf^ Activity JfeltlAndroid VilliVm -^««^KtliSIMtM Activity*

1. JgSfr—MiffiW Activity mmwm f Activity, JS3&—Mifefcj Activity ffl. Context Activity (ft class ^ Intent, Intent startActivity /j&BPhT,

I Intent intent new Intent(CurrentActivity.this,OtherActivity.class>; startActivity(intent);

"i-Wr filt- startActivity tfjfjiiifi, ^MifW Activity, l£in«ta®fJ-t&liKj OtherActivity tttiftjft. M-E&mfi-t Activity AWMSHift.

2. Activity

Activity, Activity fftjffi iftttllttSM Intent fijtfl. *JgfhjMt£*tt*lKB*)fitt Activity Sff-M-I^W&fifc i'fl. ittam'-® •• m Activity, It ^W&i KMmir. Activity

Iflifi&iaJ&iEftfium Activity Wffij^mSffi^KWiS. »^StmH^rW Activity iftfl^T. fifijitU. KiSW

Intent intent = new Intent(Intent.ACTION DIAL, Uri.parse("tel:115-1345")); startActivity(intent);

Activity ¿tfcfr. Activity Intent VK

W>yA ^Mt startActivity /jviin, Android «MS*^ Activity «^ifi. «frtiSiK

flSafifAttfiJitbaHiiSM Activity, tAiio

3 ^ Activity MilHit

Bifiiffiff]^® T startActivity (l<J Activity, Activity ftir'/tin ,

¡EMftlKi&llif -t" Activityq )f\VI Android 7 B^h-ft startActivityForRcsult /jtt.HJ t Activity jj ILffM Activity MiicSgi®jgMfJtfs/j'S

M Activity itinaffjjijw -t r- Activity, jfjia^^/-Activity «inwrwAfc

37- Activity jg|B|OCjft#i. fWfrl KW/F:

public void onCreate(Bundle savedlnstanceState) i super . onCreate (savedlns'anceState) ; listenerl new OnClickListeller () { public void onClick(View v) |

Intent intentl = new Intent(ActivityMairi.this, Activityl.class); intent 1 .putExtra ("activityMain", activityMain") ;

startActivityForResult(intentl, REQUEST_CODE); )

listener? = new GnClickList.ener () { public void onclick(View v) ( setTitle ActivityMain") ;

Intent intent.2 - new Intent(ActivityMain.this, Activity2.class); startActivity(intent2);

setContentView(R.layout.main);

button1 = (Button) findViewByld(R.id.buttonl); button I.setOnClickListener(listener!); but ton2 = (Button) findViewByld(R.id.button?); button?.setOnClickListener(listener?);

setTitle("ActivityMain");

(? Over ride protected void onActivityResult(int requestCode, int resultCode, Intent data) ( if (requestCode == REQUEST CODE) ( if (resultCode == RESULT CANCELED) setTitle ("M") ;

else if (resultCode == RESULT OK) { String temp=null;

Bundle extras = data.getExtras(); if (extras ! null) { temp = extras.getString("store"); )

• ScffJiSBl starlActivityForResult (intend, REQUEST CODE) i Activity 1«

• -ttiPSaffliiliitilWIJ Activity ir\ J/AMi^J t Activity ffl^ftfl Jft&ft- f Activity ftj lfli®1f]J^iiil®/f3 ^nlij Activity S't'lW onActivityResult (int requestCode, int resultCode, Intent data) SY Activity Android fIAft&iHffliifXftt.

Activityi ty&mmik&mi, imtorvr*:

public void onCreate(Bundle savedlnstanceState) ( super.onCreate(savedlnstanceState); setContentView(R.layout.activityl); listenerl new OnCiickListener() ( public void onClic.k (View v) 1 Bundle bundle - new Bundle();

bundle.putString ("store", Activityl") ;

Intent mlntent =• new Intent(); nilntent.putExtras (bundle) ; setResult(RESULT OK, mlntent); fi nish(); )

W] "jftH" -Intent in Broadcast

buttonl = (Button) findViewByld(R.id.button3); buttonl.setOnClickListener(listenerl); String data-null;

Bundle extras = get Intent().getExtras(); if (extras != null) ]

data extras.getString("activityMain");

setTitle(,,SiH9Eft# Activityl M:"+data); }

• fjMWM:setResulHRESULT OK,mlntent),/ Activityl fttrSjftBiftlWiSI»]«. WWi»®®®»^*«-^ intent «ii, itfct intent

requestCode. rcsultCode «,

• startActivityForRcsult < Intent intent, int requestCode).

• Intent, Intent til^ T W^S^JW Activity (Mn&o

• ^ffiiffllPlB^ttJiill*».»^«*«^^ onActivityRcsult ^•ffi'Uii^i&Ho tt^rWiffiH'^RWiS^Wi/rl^I--^ Activity, jonActivityRcsult

• onActivityResult (int requestCode, int resultCode, Intent data)«

• f Activity W setResult (int resultCode, Intent data)

«SfliWWft't. -t ^ RESULT OK . Activity & W ' ^ ft

9.1.3 Intent

A Android + , *J Intent XftiMi(ft—^«lIMBifi ffiffJ

t Intent

• X5fft,iT«lfiW»Jin«J&atT«lii: 3S»J (category).

1. Android Action

Android TiK^^MHW Action. itfl ACTION MAIN, ACTION VIEW ^f, Kiilj-ffiffJ

• ACTION MAIN , fcttfcSmit«»«». "android.intent.action.MAIN", à^iSMJ&fiÎ^ AndroidManifest.xml A'^'l'ipôjy.fl-fij,, -¿^kll-iliij Activity ^fé/T-fKlAP.

• ACTION VIHW, ACTION VIEW jffi'£in*!f£ft<J data . Jlj f »ffl^iiS*«.

. ACTION DIAL, Jfl-flfi&i&fflPfrHiiAffttfjtt ■ Mil'ill data data fflfflPfTifeiS.

. ACTIONPICK. MVlW.^mmttZifâVktt*

. ACTION_DELETE . MftttËMgfeftS.

URI MM ContentURI android.net.ContentURI ^ffiifV

W action/ data AK't'ffJSIiiiMjSffl:

• VIEWACTION contcnt://contacts/l M /FfeHJtf^; 'M " fft ©c ^ A J VÉ Sfl Is :

• EDIT ACTION content://contacts/l

• VIEW ACTION content://contacts/ S /) ; ffr ii ft A ÎÛ H & ;

• PICK ACTION content://contacts/ M^flrWfôjgÀM?!!^. #

ft Activity. Willi, »& r-ÎII5ft:^/,,îS''rWfiliJIJjit Intent.

3. Intent ^WSteMtt^tS

Action 'VK^ fimhU FRfefî KiMjtàtii.

• (category), Mittl. LAUNCHERCATEGORY &<]< Intent

Launcher ifij ALTERNATIVE CATEGORY ^Sli'Ilft Intent ji- -mmw&mmitt]-^.

. mft (component), Î&ÎË Intent W R^U'tM^^^. iffi'fô Android Intent »f&ft

ÎB action, data/type, category UtÎT^tt- M^ttSJ "t^'¿Efimi Witt. ÎH&, Ui'M component tëAfê TO^W&ÎTiiËSfSii

• WillfëE (extras), MKteffiÎJ ffiMii&MiLft. fêJfl extras ^

Was this article helpful?

0 0

Post a comment