Android labelRes is 0

LonsomeHell Source

I am using int stringID = context.getApplicationInfo().labelRes to get the application name resource ID. Then I use context.getString(stringID) to get the application name. I get

 W/ResourceType: No package identifier when getting value for resource number 0x00000000
    android.content.res.Resources$NotFoundException: String resource ID #0x0

Any idea why labelRes is 0?

javaandroidandroid-resources

Answers

answered 6 days ago medbenjemaa #1

try this one it may help you

public static String getApplicationName(Context context) {
    ApplicationInfo applicationInfo = context.getApplicationInfo();
    int stringId = applicationInfo.labelRes;
    return stringId == 0 ? applicationInfo.nonLocalizedLabel.toString() : context.getString(stringId);
}


String appName=getApplicationName(context);

comments powered by Disqus