Get the original application name without localization

I need to get application names, but without a local language, only in the original language. I am from Poland and I need a list of application names in original English! I have a code:

final PackageManager packageManager = context.getPackageManager();
final Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.LAUNCHER");
final List<ResolveInfo> activities = packageManager.queryIntentActivities( intent, 0 );
final int size = activities.size();
for (int i = 0; i < size; i++){
    final ResolveInfo info = activities.get(i);
    final String label = info.loadLabel(packageManager).toString();
    final String pkgName = info.activityInfo.packageName;
    final String className = info.activityInfo.name;
    Log.d("INFO", label);
}
+3
source share
1 answer

You can use getResourcesForApplication()from package manager. You can establish a culture of resources and get values.

Please check the code below

PackageManager packageManager = getPackageManager();
final String packageName = "com.android.wallpaper.livepicker";
    try {
        ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA);

        if (null != applicationInfo) {
            CharSequence label = packageManager.getApplicationLabel(applicationInfo);

            Log.d("MyTag", "Default app label is " + label);

            Configuration configuration = new Configuration();

            configuration.setLocale(new Locale("en"));

            Resources resources = packageManager.getResourcesForApplication(packageName);

            resources.updateConfiguration(configuration, getBaseContext().getResources().getDisplayMetrics());

            String localizedLabel = resources.getString(applicationInfo.labelRes);

            Log.d("MyTag", "Localized app label is " + localizedLabel);
        }
    } catch (PackageManager.NameNotFoundException e) {
        Log.e("MyTag", "Failed to obtain app info!");
    }
0
source

All Articles