Here you can find the source of getAppPackage(Context context)
public static PackageInfo getAppPackage(Context context)
//package com.java2s; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; public class Main { public static PackageInfo getAppPackage(Context context) { PackageInfo appPackage = null;/* w ww. j av a 2 s. co m*/ try { appPackage = context.getPackageManager().getPackageInfo( context.getPackageName(), 0); } catch (NameNotFoundException e) { e.printStackTrace(); } return appPackage; } }