我不知道。当SD卡打开时,我如何自动安装apk?
然而,我遇到了一个问题,当我在AndroidManifest.xml Em中注册侦听ACTION_MEDIA_SHARED
的接收器时……我创建了一个扩展BroadcastReceive
的接收器,我覆盖了OnReceive()
。但是,最终,接收方无法获得任何行动。这是我的密码。令人沮丧!!!!!
<receiver android:name=".SdcardPutOnListener"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.ACTION_MEDIA_BAD_REMOVAL" />
<action android:name="android.intent.action.ACTION_MEDIA_MEDIA_CHECKING" />
<action android:name="android.intent.action.ACTION_MEDIA_EJECT" />
<action android:name="android.intent.action.ACTION_MEDIA_MOUNTED" />
<action android:name="android.intent.action.ACTION_MEDIA_NOFS" />
<action android:name="android.intent.action.ACTION_MEDIA_REMOVED" />
<action android:name="android.intent.action.ACTION_MEDIA_SHARED" />
<action android:name="android.intent.action.ACTION_MEDIA_UNMOUNTABLE" />
<data android:scheme="file" />
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</receiver>
public class SdcardPutOnListener extends BroadcastReceiver {
final static String TAG = "SdcardPutOnListener";
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "receive broadcast " + intent.getAction());
}
}
您可以创建一个应用程序来监视ACTION_MEDIA_MOUNTED
广播,然后在已知位置查看APK文件的外部存储,然后在该APK文件路径上使用ACTION_VIEW
Intent
调用startActivity()
,并使用正确的MIME类型(application/vnd.android.package-archive
)。
如果您希望将其内置到操作系统中,那么事实并非如此。