2011-04-21 179 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帮助ü

相关问题