Created
August 1, 2019 08:18
-
-
Save Minishlink/69b58caec55efeef42d39c225eb714e4 to your computer and use it in GitHub Desktop.
RootBeer example
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
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
SplashScreen.show(this); | |
if (!BuildConfig.DEBUG && !BuildConfig.SKIP_ROOT_CHECK) { | |
RootBeer rootBeer = new RootBeer(this); | |
if (rootBeer.isRootedWithoutBusyBoxCheck()) { // isRooted has false positives (OnePlus devices and MotoE) | |
AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
builder.setMessage("You cannot use this app on a rooted device.") | |
.setPositiveButton("OK", new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog, int id) { | |
exitApp(); | |
} | |
}) | |
.setOnDismissListener(new DialogInterface.OnDismissListener() { | |
@Override | |
public void onDismiss(DialogInterface dialog) { | |
exitApp(); | |
} | |
}) | |
.show(); | |
} | |
} | |
super.onCreate(savedInstanceState); | |
} | |
private void exitApp() | |
{ | |
if (Build.VERSION.SDK_INT >= 21) { | |
finishAndRemoveTask(); | |
} else { | |
finish(); | |
} | |
System.exit(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment