Skip to content

Instantly share code, notes, and snippets.

@wangmuy
Last active August 30, 2016 10:05
Show Gist options
  • Save wangmuy/c60a1fc694151067c01cbd04fe6c5133 to your computer and use it in GitHub Desktop.
Save wangmuy/c60a1fc694151067c01cbd04fe6c5133 to your computer and use it in GitHub Desktop.
android.media.MassStorageDevice
// http://stackoverflow.com/questions/7142987/media-mounted-broadcast-not-being-received
// 静态 BroadcastReceiver
<receiver
android:name=".MediaMountedReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.MEDIA_MOUNTED" />
<data android:scheme="file" />
</intent-filter>
</receiver>
// 动态
IntentFilter mountedIF = new IntentFilter(Intent.ACTION_MEDIA_MOUNTED);
mountedIF.addDataScheme("file");
this.registerReceiver(mMountedReceiver, mountedIF);
IntentFilter unmountedIF = new IntentFilter(Intent.ACTION_MEDIA_UNMOUNTED);
unmountedIF.addDataScheme("file");
this.registerReceiver(mUnmountedReceiver, unmountedIF);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment