确定Android包是由供应商pinstalled $ P $是由、供应商、Android、pinstalled

2023-09-05 09:08:06 作者:贵在坚持

我不知道是否有一种方法可以知道,我的应用程序是由供应商pinstalled(以及从Android Market没有安装)$ P $。应用也是在Android Market中可用,并且可以从那里进行更新。

I wonder whether there is a way to know that my app is preinstalled by vendor (and not installed from Android Market). Application is also available in Android Market and can be updated from there.

一个解决方法是在本地文件系统中创建一个文件(我们可以建立一个特殊的应用程序版本供应商)。但有一种情况,即应用程序可以从市场上更新了它的第一次运行前,并没有创建的文件。

One solution is to create a file in the local file system (we can build a special app version for vendor). But there is a case that application can be updated from the market before its first run, and file is not created.

那么,有没有其他办法?也许,安装路径?

So is there any other way? Probably, installation path?

另外它们也同样吸引这$ P $不管Android Market的应用程序检查,像它的谷歌地图进行pinstalled应用程序的自动更新。

Also it's interesting whether Android Market app checks this preinstalled app for updates automatically like it's performed for Google Maps.

推荐答案

您必须让你的包ApplicationInfo(与PackageManager),然后检查它的标志。

You have to get the ApplicationInfo of your package (with the PackageManager) and then check its flags.

if (android.content.pm.ApplicationInfo.FLAG_SYSTEM & myApplicationInfo.flags) != 0)
   // It is a pre embedded application on the device.