As shown below:
public class Logutils {public
static Boolean app_dbg = FALSE;/is debug mode public
static void init (Context conte XT) {
app_dbg = isapkdebugable (context);
}
/**
* But when we don't set its Debug property in Androidmanifest.xml:
* Its Debug property is true when packaged with eclipse running this way. The Debug property is False when you use eclipse export this way to package.
* When you use Ant to package, the value depends on whether the ant packaging parameter is release or Debug.
* Therefore, it is best not to set the Android:debuggable attribute in the Androidmainifest.xml, but to decide its value by the packaging method.
*
@param context
* @return
* @author shanhy
* @date 2015-8-7
/public static Boolean isapkdebugable (Context context) {
try {
applicationinfo info= context.getapplicationinfo ();
Return (info.flags&applicationinfo.flag_debuggable)!=0;
} catch (Exception e) {
} return
false;
}
}
In project development, we output the log according to the debug attribute.
But there are times when we want to print out the release version that is installed on the company's test machine, so this time we go to the application tag in Androidmanifest.xml to add the attribute force setting debugable, as follows:
<application android:debuggable= "true" tools:ignore= "Hardcodeddebugmode" ...
.
.../>
The Init method executes in the OnCreate method of the first activity of the client.
The above Android judgment is to develop the debug mode, or Release mode is the way to distribute the whole content of the small series, I hope to give you a reference, but also hope that we support cloud habitat community.