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

Discussion in 'Android Questions' started by Silv, Feb 3, 2015.

  1. Silv

    Silv Member Licensed User

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

    DonManfred Expert Licensed User

    With Androiid 5.x you can use the Storage-Library...
     
  3. Erel

    Erel Administrator Staff Member Licensed User

  4. Silv

    Silv Member Licensed User

    Something no work for me.
    I added 2 permissions
    Code:
    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.

    Code:
    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
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Are there any relevant messages in the logs? Check the unfiltered logs as well.
     
  6. JakeBullet70

    JakeBullet70 Well-Known Member Licensed User

    This works.

    Code:
    AddPermission(android.permission.MEDIA_MOUNTED)
    AddReceiverText(s1,
    <
    intent-filter>
        <action android:name=
    "android.intent.action.MEDIA_MOUNTED" />
        <data android:scheme=
    "file"/>
    </
    intent-filter>)
     
    Silv, Erel and DonManfred like this.
  7. Silv

    Silv Member Licensed User

    Thanks dad :)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice