I need to get the broadcast receive when media is unmounting i.e before it is being unmounted.
So that i can save the file in SD Card before Media is unmounted.
i used android.intent.action.MEDIA_UNMOUNTED.
<intent-filter>
<action android:name="android.intent.action.MEDIA_UNMOUNTED" />
<data android:scheme="file" />
<category android:name="android.intent.category.HOME" />
</intent-filter>
But it received after the media was unmounted and then I was not able to save the file.
I also tried MEDIA_EJECT, MEDIA_SHARED, all this are received after Media is Unmounted.
Is there any other way to save the file. I don't want to use Thread for saving File.
Use ACTION_MEDIA_EJECT: User has expressed the desire to remove the external storage media. Applications should close all files they have open within the mount point when they receive this intent. The path to the mount point for the media to be ejected is contained in the Intent.mData field.
try android.intent.action.ACTION_MEDIA_UNMOUNTED
it should receive broadcast. but i am not sure. never used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With