Java tutorial
//package com.java2s; // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; public class Main { public static String getApplicationName(Context ctx) { ApplicationInfo ai; try { Context appContext = ctx.getApplicationContext(); assert appContext != null; final PackageManager pm = appContext.getPackageManager(); assert pm != null; ai = pm.getApplicationInfo(ctx.getPackageName(), 0); return (String) (ai != null ? pm.getApplicationLabel(ai) : "(unknown)"); } catch (Exception ignored) { } return null; } }