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).

	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.

		if (BuildConfig.DEBUG)
			mes(LoginActivity.this, "DEBUG");
		else
			mes(LoginActivity.this, "RELEASE");

 

User in reverse mode

A funny user writes

By: |17/02/2014|