Get App Name : System « Development « Android






Get App Name

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

class Main {

  public static String getAppName(Context ctx, String pkgName) {
    try {
      PackageManager pm = ctx.getPackageManager();
      ApplicationInfo appInfo = pm.getApplicationInfo(pkgName, 0);
      String label = pm.getApplicationLabel(appInfo).toString();
      return label;
    } catch (NameNotFoundException e) {
      return "";
    }
  }
}

   
    
    
    
  








Related examples in the same category

1.Run System Command
2.Get Process ID with shell command and read by Java code
3.Check For Installed App
4.Get Api Level
5.Exec And Wait