我开发了一个Android应用程序。我希望大家从playstore下载它。我想知道是否有任何方法来检查我的Android应用程序是从Playstore还是其他市场安装的? 我想通过检查我可以让我的应用更安全。
答案 0 :(得分:0)
嗯,我不确定,但在分析了我使用谷歌播放安装的软件包后,我说你可以使用软件包管理器命令形式shell,并且会有本机实现。 所以我的分析是从Google Play商店安装 installer = com.android.vending 的软件包
pm list packages -i
shell @ Colors_X47:/ $ pm list packages -i 包:com.google.android.ears installer = null package:com.android.defcontainer installer = null 包:com.android.quicksearchbox installer = null package:com.android.smsregister installer = null package:com.android.contacts installer = null package:com.mediatek.voiceunlock installer = null package:com.mediatek.lbs.em installer = null package:com.android.phone installer = null package:com.android.calculator2 installer = null package:net.cactii.flash2 installer = null package:com.android.htmlviewer installer = null 包:com.google.android.gsf.login installer = null 包:com.azmathunzai.lebcms installer = null 包:jackpal.androidterm installer = com.android.vending package:com.android.wallpaperchooser installer = null 包:com.google.android.tts installer = com.android.vending package:com.android.providers.telephony installer = null package:com.mediatek.schpwronoff installer = null package:com.mediatek.CellConnService installer = null
新发现: You can use String getInstallerPackageName (String packageName) Follow link
答案 1 :(得分:0)
使用PackageManager
执行此操作:
public void licenseChecker() {
String mSource = getApplicationContext().getPackageManager()
.getInstallerPackageName(getApplicationContext().getPackageName());
if (mSource != null && mSource.startsWith("com.android.vending")) {
// YOUR LOGIC HERE
Log.d("*** Success Checker", "Play Store");
} else {
// YOUR LOGIC HERE
Log.d("*** Failure Checker", "Other Market");
}