In Android 6.0, MTP no longer works automatically:
Device connections through the USB port are now set to charge-only mode by default. To access the device and its content over a USB connection, users must explicitly grant permission for such interactions. If your app supports user interactions with the device over a USB port, take into consideration that the interaction must be explicitly enabled.
MTP needs to be re-authorized at least every time you plug in the USB cable, and possibly more frequently than that (timeouts?).
With USB debugging enabled, the only solution that I have found to get MTP sharing to work on the device is to:
This is aggravating when you are trying to work with a device's files on external storage.
Is there a command-line way to get MTP going, short of writing a UIAutomator "test" that automates the above process? Or, is there some other way to get MTP to work without this sort of prep process?
Reboot your device. Now go to "Settings-->Developer options" and enable "USB debugging". Then tap on "Select USB configuration" and select the option "MTP(Media Transfer Protocol)".
Go to Settings. Tap System > Developer options. Go to USB debugging and flip the switch to turn it off.
In Marshmallow (6.0 and 6.0.1) it is not possible without some sort of super power :-(
adb shell svc usb setFunction mtp
throws java.lang.SecurityException: Neither user 2000 nor current process has android.permission.MANAGE_USB.
and MANAGE_USB
is a signature|privileged
permission. I filed this as issue#193062. It has been put into state Assigned and labeled as Defect-25596495. It is fixed in N developer preview.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With