我想在我的应用 ABCD 上进行验证。我在我的应用程序中添加了将其发送到其他设备的功能。我可以通过蓝牙将我安装的应用 ABCD 从我的设备发送到其他设备。现在,我要创建检查。
if(isFromPlayStore){
// always valid downloaded from play store
}else{
// trial version expired in 30 day
}
请看这里。这可能会帮助您了解一些想法。
普通用户下载应用程序有两种最常见的方式。
“com.android.vending”是 Google Play 商店,
“com.amazon.venezia”是亚马逊应用商店,
侧载时为“null”(来源不明)
要检查这一点,请使用以下代码:
final PackageManager packageManager = getPackageManager();
try {
final ApplicationInfo applicationInfo = packageManager.getApplicationInfo(getPackageName(), 0);
if ("com.android.vending".equals(packageManager.getInstallerPackageName(applicationInfo.packageName))) {
// App was installed by Play Store
} else if ("com.amazon.venezia".equals(packageManager.getInstallerPackageName(applicationInfo.packageName))) {
// App was installed by Amazon Appstore
} else {
// App was installed from somewhere else
}
} catch (final NameNotFoundException e) {
e.printStackTrace();
}