I need to write some util class by myself and I need the packagename of android app.
While I found the packageManager which only can be used in Activity and so on that has context. I only want to get packagename in my class which will be used in android app. So how can I do this? Thank you!
I need to write some util class by myself and I need the packagename
Share
Use :
getPackageManager().getPackageInfo(getPackageName(), 0).packageNameOr just
MyContext.getPackageName()You can also create a function: