Android Question How can i check if media is plugged in?

Silv

Member
Licensed User
Hi all, is anybody know how to check if media (for example sd card or usb) was plugged in?
Thanks.
 

DonManfred

Expert
Licensed User
With Androiid 5.x you can use the Storage-Library...
 
Upvote 0

Silv

Member
Licensed User
Something no work for me.
I added 2 permissions
B4X:
AddPermission(android.permission.MEDIA_MOUNTED)
AddReceiverText(s1,
<intent-filter>
    <action android:name="android.intent.action.MEDIA_MOUNTED" />
</intent-filter>)

Then i created a service s1 which should run anytime when media mounted.

B4X:
Sub Service_Start (StartingIntent As Intent)
   
   If(StartingIntent.Action = "android.intent.action.MEDIA_MOUNTED") Then
     
     ToastMessageShow("media has been mounted",True)
     Log("media has been mounted")
     
   End If
   
End Sub
 
Upvote 0

JakeBullet70

Well-Known Member
Licensed User
This works.

B4X:
AddPermission(android.permission.MEDIA_MOUNTED)
AddReceiverText(s1,
<intent-filter>
    <action android:name="android.intent.action.MEDIA_MOUNTED" />
    <data android:scheme="file"/>
</intent-filter>)
 
Upvote 0
Top