2016-05-31 150 views
3

我想检查并允许使用我的应用程序,只要它已从Play商店下载并且尚未被其他用户或任何其他来源共享。如果没有从Google Play商店下载应用,我如何阻止用户使用该应用?检测是否从Play商店安装了应用程序

+0

可能重复[如何知道应用程序是从谷歌播放还是侧装?](http://stackoverflow.com/questions/10809438/how-to-know-an-application-is-installed-从-谷歌播放-或侧负载) –

回答

8

此方法将检查您的应用是否已从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(这个)。

相关问题