I want to detect whether any debug tool is attached to a android device. I want this feature so that no one can see logs when app is released to people.
Regards.
PS:
I want to write log even in Production environment as they’ll help me fine tune my app but don’t want anyone else to see them.
you can’t detect if USB debugging is connected or enabled without being a system application. however, we can talk about how to solve your problem. if you don’t want your app to log on your official market release, there’s a couple of acceptable ways to go about it,
conditionally log. wrap all your log messages like this,
before you build your official market APK, set
DEBUGto false in your code. a slightly nicer way of doing this is to add a wrapper method or class around android’s logger. e.g., write a method like this,use proguard. proguard is a tool that manipulates bytecode after compilation. you can use it to remove all logging from your code (among other things). there’s quiet a learning curve to get going with proguard, but it’s very powerful.
here’s another post that gives the topic some in-depth discussion.
How do I enable/disable log levels in Android?