有没有一种方法来检测,如果应用程序是用市场或没有安装?方法来、应用程序、没有安装、市场

2023-09-12 07:11:49 作者:现实太狗

我想知道如果我能发现,如果我的应用程序与Android市场(它在市场的下载列表和资格更新检查)安装或它不是?

I am wondering if I am able to detect if my application was installed with Android Market (it's in the download list of the Market and eligible for update checks) or it's not?

这将是一个非常好的问题,以检测应用程序已不被安装,因为这可能意味着它被偷走,并安装了SD卡。

It would be a very good point to detect if the app has been installed without, as that can mean it was stolen and installed from SDcard.

推荐答案

在你的活动做


PackageManager pm = getPackageManager();
String installationSource = pm.getInstallerPackageName(getPackageName());

installationSource现在认为,安装在您的应用程序中的应用程序的包名。

installationSource will now hold the package name of the app that installed your app.

测试与煤矿安装源的应用程序是在通过谷歌电子市场安装com.google.android.feedback,NULL,如果通过调试安装。

testing with an app of mine installation source is "com.google.android.feedback" when installed via google market, null if installed via debugger.