Created
June 18, 2014 10:24
-
-
Save derFunk/2f676b17eb5a26b89ba7 to your computer and use it in GitHub Desktop.
Reliably Detect ART Runtime on Android KitKat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Checks if the device is using the (still experimental Android Runtime (ART)) | |
* @return Returns true if ART is used on the device. | |
*/ | |
public static boolean isART() | |
{ | |
if (Build.VERSION.SDK_INT < 19) // Before KITKAT, as ART is only available since 4.4.x | |
return false ; | |
try{ | |
String bootClassPath = System.getProperty("java.boot.class.path", ""); | |
if (bootClassPath.contains("core-libart.jar")){ | |
Log.d(TAG, "java.boot.class.path contains core-libart.jar - Using ART :("); | |
return true; | |
} | |
else { | |
Log.d(TAG, "java.boot.class.path does not contain core-libart.jar - Not using ART :)"); | |
return false; | |
} | |
} | |
catch(Exception e){ | |
android.util.Log.d(TAG, e.toString()); | |
} | |
// If not found - return false because if when | |
// returning true, and there is no ART, it would | |
// be worse to display a popup "you cannot play, you're using ART", | |
// instead of crashing the app instantly | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment