get App Label - Android android.os

Android examples for android.os:PowerManager

Description

get App Label

Demo Code

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Environment;
import java.io.File;
import java.lang.reflect.Field;

public class Main{

    public static String getAppLabel(Context paramContext) {
        try {/*from  w w  w . j av a  2  s.  c om*/
            PackageManager localPackageManager = paramContext
                    .getPackageManager();
            paramContext = paramContext.getPackageName();
            if ((localPackageManager != null) && (paramContext != null)) {
                paramContext = localPackageManager
                        .getApplicationLabel(
                                localPackageManager.getPackageInfo(
                                        paramContext, 1).applicationInfo)
                        .toString();
                return paramContext;
            }
        } catch (PackageManager.NameNotFoundException paramContext) {
            paramContext.printStackTrace();
        }
        return null;
    }

}

Related Tutorials