我想检查并允许使用我的应用程序,只要它是从 Play 商店下载的,并且它没有被其他用户或任何其他来源共享。如果应用不是从 Google Play 商店下载的,我该如何阻止用户使用该应用?
最佳答案
此方法将检查您的应用是否已从 Play 商店安装。
boolean verifyInstallerId(Context context) {
// A list with valid installers package name
List<String> validInstallers = new ArrayList<>(Arrays.asList("com.android.vending", "com.google.android.feedback"));
// The package name of the app that has installed your app
final String installer = context.getPackageManager().getInstallerPackageName(context.getPackageName());
// true if your app has been downloaded from Play Store
return installer != null && validInstallers.contains(installer);
}
几天前我发布了一个 Android 库,PiracyChecker ,它使用一些技术保护您的应用程序,例如 Google Play 许可 (LVL)、APK 签名保护和安装程序 ID(这一项)。
关于android - 检测是否从 Play 商店安装了应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37539949/