如何在库模块的代码内部获取主applicationId? [英] How to get main applicationId inside code in the library module?
本文介绍了如何在库模块的代码内部获取主applicationId?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个库模块,我想通过Intent(String)进行starService.当我设置时:
I have library module where I'd like to starService through Intent(String). When I set:
Intent intent1 = new Intent(BuildConfig.APPLICATION_ID + ".REFRESH_DATA");
我的BuildConfig.APPLICATION_ID是一个库包.我的代码中需要一个变量,该变量将由主应用程序包填充.
My BuildConfig.APPLICATION_ID is a library package. I need a variable in my code which will be populated with the main app package.
推荐答案
只需使用context.getPackageName().
Just use context.getPackageName().
https://developer.android.com/studio/build/application- id#change_the_package_name
这篇关于如何在库模块的代码内部获取主applicationId?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文