简体   繁体   English

如何从图书馆计划中的活动中确定Android应用程序版本是专业版还是精简版?

[英]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.myappcom.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.

相关问题 如何将我的Android应用程序从Lite升级到Pro版本 - How to upgrade my android application from lite to pro version 升级时保持相同的SQLite数据库,从Lite到Pro版本升级Android应用程序 - Keeping the same SQLite database when upgrading and Android app from Lite to Pro version 如何使Lite / Pro版本的应用程序功能与所引用的库略有不同 - How to make lite/pro versions of app function slightly different from the referenced library 如何解决在将库添加到另一个项目以制作我的Android应用程序精简版的Dalvik错误? - How to solve the Dalvik error in adding libs to another project to make a Lite version of my Android app? 如何实现专业版Android应用 - How to implement pro version android app 如何从Library项目向Android项目添加活动? - How to add activity from Library project to the android project? 是否可以从Android中的库项目访问App的版本? - Is it possible to access App's version from library project in Android? 将数据从lite移动到Pro移动应用 - Moving data from lite to pro mobile app 如何确定 Android 库的正确版本? - How determine the proper version of an Android library? Lite / Pro版本与应用内结算升级选项 - Lite/Pro version vs In-app-billing upgrade option
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM