Java tutorial
//package com.java2s; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> sAvalibleAppsPackages = new ArrayList<>(); public static List<String> getsAvalibleAppsPackages(Context context) { if (sAvalibleAppsPackages.isEmpty()) { sAvalibleAppsPackages.add(context.getPackageName()); sAvalibleAppsPackages.add(getCallerPackageName(context)); sAvalibleAppsPackages.add("com.android.incallui"); sAvalibleAppsPackages.add(getLauncherPackageName(context)); } return sAvalibleAppsPackages; } public static String getCallerPackageName(Context context) { Intent intent = new Intent(Intent.ACTION_DIAL); ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); return resolveInfo.activityInfo.packageName; } public static String getLauncherPackageName(Context context) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); return resolveInfo.activityInfo.packageName; } }