Reputation: 903
I am developing an android-library project which is then can be added as a module dependency to android-UI project. May I know, is there a way to get a package name and version of Parent project from the module dependency?
Upvotes: 3
Views: 1339
Reputation: 1006779
Given a Context
, call getPackageName()
on the Context
to find out the package name of the app. Given the Context
and the package name, you can call getPackageManager().getPackageInfo()
on the Context
to get a PackageInfo
object for the app, which contains versionCode
and versionName
.
Upvotes: 5