我想要在安裝時監視應用程序。我知道我應該使用廣播接收器,並且我還應該添加如何在接收器中使用<intent-filter>
<receiver android:name="com.gr.xxx">
<intent-filter >
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REPLACED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
in the mainifest。但是,如果我不寫這<data android:scheme="package"/>
它不會工作。
我的問題是:我怎麼知道是否應該寫<data>
或不。我應該在計劃中寫什麼?
'android.intent.action.PACKAGE_ADDED'是一個系統動作。 **源代碼**在哪裏?因爲你說「你會遇到這個更多,」>我找不到意圖,因爲我只知道動作名稱。我不知道包和類。所以我不能得到意圖的代碼 –
@gus_gao_CHINA:「源代碼在哪裏?」 - https://source.android.com某處。您不應該需要它來響應這些「意圖」操作。請參閱https://github.com/commonsguy/cw-omnibus/tree/master/Introspection/SAWMonitor獲取示例項目,該示例項目將偵聽您的問題中添加和替換的操作。 – CommonsWare
謝謝。只是另一個問題:例如,當我想要使用此操作'ACTION_MEDIA_UNMOUNTED'我怎麼知道我應該設置'scheme = file'而不是'content'或其他東西?當我使用內容提供者時,我可以在源代碼(提供者)中獲得uri。 –