5 February 2013

How to check is USB in Android is in debug mode, code example

For API 3-16

int debugMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.ADB_ENABLED, 0);
if(debugMode==1){
//debug mode active
}

if(debugMode==0){
//debug mode NOT active
}

For API 17+
int debugMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Global.ADB_ENABLED , 0);


if(debugMode==1){
//debug mode active
}

if(debugMode==0){
//debug mode NOT active
}