[英]How to determine if Android app version is pro or lite from an Activity in a Library Project?
I'm currently changing my free version to a lite+pro combo by using a library to hold all of the important code, including my activities. 我目前正在通过使用库来保存所有重要代码(包括我的活动),将我的免费版本更改为lite + pro组合。 Essentially what I plan to do is have a one-line in the code check if the app running is the pro or lite version, and modify the app's appearance and functionality accordingly.
基本上我打算做的是在代码中检查一行,检查运行的应用程序是专业版还是精简版,并相应地修改应用程序的外观和功能。 I'm just not sure what that line should be.
我只是不确定那条线应该是什么。
So say my activity being launched from the manifest is com.example.myapp.lib.MainActivity
, and my two packages are com.example.myapp
and com.example.myapp.pro
. 所以说我从清单启动的活动是
com.example.myapp.lib.MainActivity
,我的两个包是com.example.myapp
和com.example.myapp.pro
。 What is a function I can call to check what the currently running package is? 我可以调用什么函数来检查当前运行的包是什么?
It occurs to me I could possibly do this through a preference.xml
file in each app. 它发生在我身上,我可以通过每个应用程序中的
preference.xml
文件来完成此操作。 Would that be better? 会更好吗?
您只需从活动中调用Activity.getPackageName即可
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.