Android: get application name inside module

I am writing an android module that I will include in some of my projects. Now I need to get the name of the application (at run time), for example. The name that is set android:labelfor the application in the manifest. Obviously, I cannot use it getResources().getString(R.string.app_name), because I cannot access the resources of a project that uses this library. Is there another way? I tried getApplicationInfo().name, but that null, and I can’t find anything else.

+4
source share
2 answers

I tried getApplicationInfo (). name but it is null

, name android:name <application>, Application .

.

loadLabel() ApplicationInfo, , android:label a <application> (, <activity>).

+3

, , . , , . context.getResources(). GetString (R.string.app_name) , .

0

Source: https://habr.com/ru/post/1657391/


All Articles