get Apk Label - Android App

Android examples for App:APK Information

Description

get Apk Label

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

public class Main {
    public static String getApkLable(Context context, String apkPath) {
        PackageManager pm = context.getPackageManager();
        PackageInfo info = pm.getPackageArchiveInfo(apkPath,
                PackageManager.GET_ACTIVITIES);
        String lable = null;//ww w  . j  ava  2  s .  com
        if (info != null) {
            ApplicationInfo appInfo = info.applicationInfo;
            appInfo.sourceDir = apkPath;
            appInfo.publicSourceDir = apkPath;
            try {
                lable = pm.getApplicationLabel(appInfo).toString();

            } catch (OutOfMemoryError e) {
                lable = null;
            }
        }
        return lable;
    }
}

Related Tutorials