以编程方式确定应用程序是否为 MarketPlace 版本
我有一个在 MarketPlace 内外提供的应用程序。
有没有办法从代码中确定应用程序来自哪里?
我有一些间接方法...
1)我可以简单地从它们是否勾选了“允许安装非市场应用程序”来推断...
2)或者我可以单独制作构建并在代码中明确它。
I have an application that's offered in and outside of the MarketPlace.
Is there a way of determining from within the code where the application came from?
I've got a few indirect methods ...
1) I could simply infer from whether they have "Allow installation of non-Market applications" ticked ...
2) Or I could just make separate builds and make it explicit in the code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果
PackageManager.getInstallerPackageName ()
为您的应用程序返回com.google.android.feedback
,然后该应用程序由 Android Market 安装。If
PackageManager.getInstallerPackageName()
returnscom.google.android.feedback
for your application, then it was installed by the Android Market.在每个版本的
android:versionName
中明确说明。如果代码可供人们编译自己的 APK,请将
android:versionName
设置为“自定义”,并在为市场构建时临时更改它。Make it explicit in the
android:versionName
of each release.And if the code is available for people to compile their own APKs, set the
android:versionName
to "custom" and just change it temporarily when building for the Market.鉴于当您擦除应用程序的缓存时,市场应用程序甚至不知道应用程序来自何处,我非常怀疑是否有任何其他方法可以找到答案。
Given that the Market application won't even know where an application came from when you wipe its cache, I very much doubt there is any other way to find out.