Reputation: 51
I have not any idea. How can I install apk automatically when the sdcard put on?
However, I have got an problem, When I register the receiver that listened to the ACTION_MEDIA_SHARED
in AndroidManifest.xml Em... I create a Receiver that extends BroadcastReceive
, I override OnReceive()
. But, finally, the Receiver can not get any Action. Here is my code. Frustrating!!!!!
<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());
}
}
Upvotes: 5
Views: 1117
Reputation: 1007474
You could create an app that watches for the ACTION_MEDIA_MOUNTED
broadcast, then looks at external storage in a well-known spot for an APK file, then calls startActivity()
with an ACTION_VIEW
Intent
on the path to that APK file, with the right MIME type (application/vnd.android.package-archive
).
If you are expecting this to be built into the operating system, it is not.
Upvotes: 3