Posts isDebug
Post
Cancel

isDebug

Solution 1 :

The following solution assumes that in manifest file you always set android:debuggable=true while developing and android:debuggable=false for application release (all done automatically by IDE, developer doesnt have to do anything).

1
2
3
4
5
6
7
8
9
10
	public static boolean isDebug(Context c) {
		try {
			PackageManager pm = c.getPackageManager();
			PackageInfo pi = pm.getPackageInfo(c.getPackageName(), 0);

			return ((pi.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0);
		} catch (Exception e) {
			return false;
		}
	}

Solution 2 :

SDK Tools, Revision 17 (March 2012) writes : Builds now generate a class called BuildConfig containing a DEBUG constant that is automatically set according to your build type. You can check the (BuildConfig.DEBUG) constant in your code to run debug-only functions.

1
2
3
4
		if (BuildConfig.DEBUG)
			mes(LoginActivity.this, "DEBUG");
		else
			mes(LoginActivity.this, "RELEASE");

User in reverse mode

A funny user writes

origin - http://www.pipiscrew.com/?p=838 android-isdebug

This post is licensed under CC BY 4.0 by the author.
Contents

Trending Tags