How can I get package name in android?

后端 未结 9 1300
耶瑟儿~
耶瑟儿~ 2020-12-11 05:14

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 c

9条回答
  •  有刺的猬
    2020-12-11 05:43

    you can get the package name of installed app:

    ArrayList res = new ArrayList();
            PackageManager pm = getApplicationContext().getPackageManager();
            List packs = pm.getInstalledPackages(0);
    

    and if you want to find the package name of your app:

    context.getPackageName();
    

提交回复
热议问题