2

enter image description here

I am developing an Android application, which connects with a Raspberry Pi hardware via the USB port. The issue is that this system dialog (as shown in the picture above) pops up every time I connect it. Requiring to tap on 'Allow' every time is resulting in bad user experience. If the user taps to 'Deny' or dismisses the dialog, the Raspberry Pi is unable to detect the connected Android device.

Is there a way to bypass this? Note that I'm using a non-root Samsung tablet powered by Android.

(Reposted the question here as suggested by someone in the comments. OP here: https://stackoverflow.com/questions/58371723/how-to-bypass-system-dialog-asking-to-allow-access-to-tablet-data-on-android-tab)

2
  • What version of OS, and have you tried all of the different states in 'Settings'->'Developer Options'->'Default USB configurations' Commented Oct 14, 2019 at 8:04
  • Android 8. As soon as I connect the Android device with the Raspberry Pi, the Default USB configurations automatically change to MTP.
    – mumayank
    Commented Oct 14, 2019 at 9:08

1 Answer 1

3

The dialog "Allow access to tablet data" is a security dialog, therefore from within an app it is not possible to "bypass" this dialog. As it is currently not yet possible to identify a PC via USB and MTP protocol (may be this is possible in future by authenticated USB) there is also no option available like "always allow this computer to access my files".

Otherwise anybody with access to an unlocked Android device could simply copy e.g. all photos and videos fro the device using USB.

The only known way is to enable the "Developer Options dialog and permanently set the option "USB configuration" to "MTP / file sharing"

Alternatively you could use Android Debug Bridge (adb) ADB instead. On adb level there is a computer authentication which allows to allow a computer permanent access to the device via USB. Of course ADB is disable by default, therefore the user first has to enable the Development menu and the enable adb.

2
  • thank you for the answer. Let me verify the same as suggested by you. Once I verify, I will accept your answer
    – mumayank
    Commented Oct 14, 2019 at 8:49
  • 1
    Unfortunately, there is no MTB/File sharing option on the Tab A. Only "Transferring files", "MIDI", "Transferring images" and "Charging phone only".
    – FractalBob
    Commented Feb 28, 2020 at 6:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .