3
我想檢查並允許使用我的應用程序,只要它已從Play商店下載並且尚未被其他用戶或任何其他來源共享。如果沒有從Google Play商店下載應用,我如何阻止用戶使用該應用?檢測是否從Play商店安裝了應用程序
我想檢查並允許使用我的應用程序,只要它已從Play商店下載並且尚未被其他用戶或任何其他來源共享。如果沒有從Google Play商店下載應用,我如何阻止用戶使用該應用?檢測是否從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,在使用一些技術,比如谷歌Play許可(LVL)保護您的應用程序,APK簽名保護和安裝ID(這個)。
可能重複[如何知道應用程序是從谷歌播放還是側裝?](http://stackoverflow.com/questions/10809438/how-to-know-an-application-is-installed-從-谷歌播放-或側負載) –