我希望通过显示Toast
来保护我的APK免受逆向工程,或者如果包名称更改,则执行某些操作,现在如果更改了包,该应用将停止工作。
if (getPackageName().compareTo("com.apk.example") != 0) {
String error = null;
error.getBytes();
}
答案 0 :(得分:0)
您需要检查您的软件包名称和应用程序ID,以确保您的应用程序未被篡改:
String yourPackageName = "com.apk.example"; // android package name
String packageName = getApplicationContext().getPackageName();
// can be different from your package name if you're using flavor
// in app.build.gradle,
String yourApplicationId = "com.apk.example";
if(packageName.equals(yourPackageName) && BuildConfig.APPLICATION_ID.equals(yourApplicationId)) {
// no problem here
} else {
// app is tampered, do something
}