Java tutorial
//package com.java2s; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; public class Main { /** * @param ctx The Android application context. * @return Application name */ public static String getAppName(Context ctx) { PackageManager packageManager = ctx.getPackageManager(); ApplicationInfo applicationInfo = null; try { applicationInfo = packageManager.getApplicationInfo(ctx.getApplicationInfo().packageName, 0); } catch (final NameNotFoundException ignored) { } return (String) (applicationInfo != null ? packageManager.getApplicationLabel(applicationInfo) : "Unknown"); } }