Enable USB debugging (under settings/applications/development) programmatically from within an app
You will need root permissions to do so from an app.
That said, it is possible to enable ADB by executing the following terminal commands:
setprop persist.service.adb.enable 1
start adbd
This blog post gives an excellent example of how to execute these commands with escalated permissions through su
.
First: Your app must be a system app
This line of code may help:
Settings.Global.putInt(getContentResolver(), Global.ADB_ENABLED, 1);
and you need this permission:
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
but after adding this permission in manifest you will get this error: Permission is only granted to system apps
which means your app must be a system app.
It's not possible without using your own custom firmware that grants access to the security settings. See thread here: http://groups.google.com/group/android-developers/browse_frm/thread/953c6f0eb0fa9bed#