get Program Name By Package Name - Android App

Android examples for App:Package

Description

get Program Name By Package Name

Demo Code


//package com.java2s;

import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;

public class Main {

    public static String getProgramNameByPackageName(Context context,
            String packageName) {
        PackageManager pm = context.getPackageManager();
        String name = null;/*  w  ww .j  a va 2  s . c  om*/
        try {
            name = pm.getApplicationLabel(
                    pm.getApplicationInfo(packageName,
                            PackageManager.GET_META_DATA)).toString();
        } catch (NameNotFoundException e) {
            e.printStackTrace();
        }
        return name;
    }
}

Related Tutorials