Saturday, 26 January 2019

Android App Won't Remember USB Permission

I am trying to stop the app I am working on from asking for USB permissions each time the USB device is disconnected. I have followed: USB device access pop-up suppression? without much luck.

The app does remember the USB device until the device is unplugged.

If it matters I am trying to connect the app to an Arduino Teensy.

This is what my manifest activity looks like

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>     <!-- For receiving data from another application -->
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"/>
        </intent-filter>
        <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/usb_device_filter" />

    </activity>
</application>

And here is my usb_device_filter file:

<?xml version="1.0" encoding="utf-8"?>

<resources>
    <usb-device vendor-id="--hidden--" product-id="--hidden--" />
</resources>

Any help is welcome.

EDIT: I also look over at the Android Developer page and they say when using an intent filter for USB connections: If users accept, your application automatically has permission to access the device until the device is disconnected.

https://developer.android.com/guide/topics/connectivity/usb/host



from Android App Won't Remember USB Permission

No comments:

Post a Comment