close

Intent主要分explicit intent和implicit兩種

這篇介紹建立方式

 

1. 官網https://developer.android.com/guide/components/intents-filters.html#Building

explicit intent
當指定好componet name時
就會是explicit intent
這時其他的properties就是可選的

01.png

 

2. implicit intent
沒指定componet name時觸發
用setAction來建立intent
如果沒有符合的app但又去啟動時則會crash
可用resolveActivity()來處理
當回傳不是null則可以順利啟動
當只有一個符合時則會立刻啟動
而有多個時系統會顯示對話方塊讓使用者挑選

02.png  

arrow
arrow
    文章標籤
    Android 建立Intent
    全站熱搜

    RX1226 發表在 痞客邦 留言(0) 人氣()