4

I want to programatically enable the USB tethering,USB debugging in android.Is it possible.What are the system permissions to be declared in manifest file.Can someone please help me out in the coding???

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
justin j
  • 41
  • 1
  • Possible duplicate of [Android - enable USB tethering programmatically - there is an app that did it for 2.3](https://stackoverflow.com/questions/9913645/android-enable-usb-tethering-programmatically-there-is-an-app-that-did-it-fo) – Sagar May 25 '18 at 09:26

1 Answers1

0

This code enables USB tethering

    public void enableTethering() {

                    Object conService= getSystemService(Context.CONNECTIVITY_SERVICE);
                    for (Method m : obj.getClass().getDeclaredMethods()) {

                        if (m.getName().equals("tether")) {
                            try {
                                m.invoke(conService, "usb0");
                            } catch (IllegalArgumentException |  
                                 IllegalAccessException | InvocationTargetException   e) {

                                e.printStackTrace();

                        }
                    }
            }
Venki WAR
  • 1,997
  • 4
  • 25
  • 38