4

I am working with usb device connection, in some devices like Oppo F1s OTG connection is disabled from settings. Check below screen shot as reference

enter image description here

I want to know:
1) How to check OTG connection enabled or not
2) how to open OTG connection setting page using intent

Jawad Malik
  • 608
  • 5
  • 21
AMD
  • 1,662
  • 18
  • 39
  • 2
    I don't think it is part of Android SDK, looks more like customization of OPPO firmware. – Vladyslav Matviienko Jul 16 '19 at 09:44
  • this behavior is provided by many device providers like oppo,vivo,xiomi so in market there are many devices having this settings even i dont find developer community for those providers. i posted here so if any buddy has out of box solution – AMD Jul 16 '19 at 09:49
  • 1
    @AMD take a look at [How to check MIUI autostart permission programmatically?](https://stackoverflow.com/a/49167712/7034327), maybe you can modify the `ComponentName` value to achive what you want – John Jul 16 '19 at 10:25
  • This might not be possible. If I understood correctly the activity class name is `com.android.settings.SubSettings`, but the code `val intent = Intent(); intent.setComponent(ComponentName("com.android.settings", "com.android.settings.SubSettings")); startActivity(intent)` does not work because the settings app does not export the activity. – user202729 May 24 '20 at 04:09
  • See also: [linux kernel - Android : How to programmatically connect/disconnect OTG - Stack Overflow](https://stackoverflow.com/questions/28280075/android-how-to-programmatically-connect-disconnect-otg) – user202729 Nov 16 '20 at 14:52
  • It's also possible to do something similar to the app "Automate" -- enable accessibility of itself (with the user confirm some stuff once), backup the old input method, set input method to "automate keyboard", open settings, use the accessibility features and the keyboard inputs to navigate and turn it on. The user will see some flash on the screen, though. – user202729 Nov 16 '20 at 15:04

1 Answers1

0

I dont know if you are still interested, but I had a similar problem. Unfortunately I only found a workarround. In my case the NFC-Switch is on the same page as the OTG-Switch. So I started an Intent to open the specific Settings-page:

Intent i = new Intent(Settings.ACTION_NFC_SETTINGS); 
startActivity(i);

Maybe there is something like this possible for your case, too :)

JuKe
  • 39
  • 1
  • 2