Enable USB debugging (under settings/applications/development) programmatically from within an app

后端 未结 5 1237
北海茫月
北海茫月 2020-12-11 03:23

Is it possible to enable USB debugging (under settings/applications/development) programmatically from within my app?

I was looking at Permission.WRITE_SETTING

5条回答
  •  旧时难觅i
    2020-12-11 04:11

    If your device has root, and API level > 17 for enable adb:

    Runtime.getRuntime().exec(new String[] {"su", "-c", "settings put global adb_enabled 1"});
    

    or (depends of su implementation)

    Runtime.getRuntime().exec(new String[] {"su", "settings put global adb_enabled 1"});
    

    For disable - change last argument from 1 to 0

提交回复
热议问题