Intent介紹及其使用方法
時間:2016-12-12作者:華清遠(yuǎn)見
1.什么是Intent Intent直譯是指意圖,目的的意思,在Android中,它是一種用來執(zhí)行一個操作的抽象描述,它可以用來啟動一個Activity,實(shí)現(xiàn)Activity之間的跳轉(zhuǎn),還可以發(fā)送廣播,啟動服務(wù)。 Intent還可以作為連接每個Activity的紐帶,在每個Activity之間傳遞數(shù)據(jù)。 2. Intent的數(shù)據(jù)結(jié)構(gòu) 一個Intent的主要信息包括: ◇action:執(zhí)行動作,比如: ACTION_VIEW, ACTION_EDIT, ACTION_MAIN等 3.Intent的使用方法 ①Intent可以從開發(fā)者自己的程序跳轉(zhuǎn)到系統(tǒng)應(yīng)用界面,比如點(diǎn)擊一個按鈕跳轉(zhuǎn)到發(fā)短信的界面,其使用方式是通過uri的方式進(jìn)行跳轉(zhuǎn),具體如下: Intent it = new Intent(Intent.ACTION_VIEW); ②啟動一個Activity,實(shí)現(xiàn)Activity之間的跳轉(zhuǎn)
Intent it = new Intent(Main.this,Second.class); ③設(shè)置需要發(fā)送的信息,通過廣播將此Intent發(fā)送出去
Intent it = new Intent(); ④啟動/關(guān)閉一個服務(wù)
Intent it = new Intent(Main.this,Second.class);
相關(guān)資訊
發(fā)表評論
|