简体   繁体   中英

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. 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 . 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. Would that be better?

您只需从活动中调用Activity.getPackageName即可

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM