How to distinguish between USB and SD mount?

I have an Android 6.0 phone with internal memory, a removable SD card and a USB OTG (pen with a USB micro-jack) inserted in the phone. A removable SD card and USB OTG were thrown into the Android equipment: "Settings" → "Storage and USB". I can install a removable SD card and USB OTG in this equipment. For example, I mount a removable SD and want to distinguish this event from the USB OTG installation. The only action I can get in the receiver

    <receiver
        android:name=".receiver.RemovableMediaReceiver"
        android:enabled="true"
        android:exported="false">
        <intent-filter>
            <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED"/>
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.MEDIA_MOUNTED"/>
            <action android:name="android.intent.action.MEDIA_UNMOUNTED"/>
            <action android:name="android.intent.action.MEDIA_EJECT"/>
            <action android:name="android.intent.action.MEDIA_BAD_REMOVAL"/>

            <data android:scheme="file"/>
        </intent-filter>
    </receiver>

on mount android.intent.action.MEDIA_MOUNTED and the path to the root of the mounted SD card as an additional for this action - / storage / A13D-EF43. The same situation occurs when installing USB OTG. The only difference is the name of the installed USB OTG - path / storage / BD 76-24ED.

, - SD USB OTG - API, SD USB OTG , () Android. intent.action.MEDIA_MOUNTED

+4

Source: https://habr.com/ru/post/1657793/


All Articles