2011-04-21 92 views
20

如果在啓動後自動啓動並安裝了Android應用程序,它是否在/sdcard上?Android - 如何在啓動後在/ SD卡上啓動應用程序

好的,可能是BroadcastReceiver。但是哪個行動是正確的?

ACTION_BOOT_COMPLETED - does not work if it is on the /sdcard (documented) 
ACTION_MEDIA_MOUNTED - does not work if it is on the /sdcard (which is undocumented) 
ACTION_EXTERNAL_APPLICATIONS_AVAILABLE - does not work, I do not know why 
ACTION_USER_PRESENT - does not work if the BroadcastReceiver is registered in AndroidManifest (which is undocumented, but documentation bug has been reported) 

由於

+0

你有沒有解決過這個問題?我現在有類似的問題。 – 2013-01-09 11:26:58

+0

您的問題幫助我找到我的答案,謝謝。 :D – 2013-08-14 14:45:19

+0

如果您覺得有幫助,您應該接受答案。 – 2015-06-03 05:41:14

回答

0

我通常(在擴展的應用的一類的Android清單以及動態地)兩種方式註冊的廣播接收機的每個意圖過濾

在AndroidManifest.xml如:

<receiver 
      android:name=".broadcastReciever" 
      android:enabled="true" 
      android:exported="true" android:permission="android.permission.RECEIVE_BOOT_COMPLETED"> 
      <intent-filter> 
       <action android:name="android.intent.action.BOOT_COMPLETED" /> 
       <action android:name="android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE" /> 
      </intent-filter> 
     </receiver> 

和在延伸的一類應用:

registerReceiver(new broadcastReciever(), new IntentFilter(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE)); 

並且不要忘記添加RECEIVE_BOOT_COMPLETED權限並在Android Manifest中註冊擴展Application的類。

這應該做的;隨時要求任何更多的幫助/澄清。

1

請在清單文件中提及它。

</uses-permission>  
<receiver android:name=".BootReceiver" 
    android:enabled="true" 
    android:exported="true" 
    android:label="BootReceiver"> 
    <intent-filter> 
     <action android:name="android.intent.action.BOOT_COMPLETED"></action> 
    </intent-filter> 
</receiver> 

提供許可「android.permission.RECEIVE_BOOT_COMPLETED」作爲宣言的孩子。

還有一件事你的應用程序一定不能安裝在SD卡中。

+0

這並沒有回答這個問題,因爲這個問題具體問了如何在SD卡上安裝應用程序*時在啓動時收到通知。 – BladeCoder 2015-07-30 00:17:14

+0

我不確定,但根據我的說法是不可能的。 – 2015-07-30 04:49:28

+0

我同意,所以正確的答案是,這是不可能的。 – BladeCoder 2015-07-30 11:24:17

0

使用<receiver android:name=".BootCompleteReceiver" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.QUICKBOOT_POWERON" /> </intent-filter> </receiver>

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

也許QUICKBOOT_POWERON幫助ü

相關問題