Android examples for App:Popular App
launch Google Plus
//package com.java2s; import java.util.List; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; public class Main { public static void launchGooglePlus(Context a, Intent targetIntent) { defineAppToLaunch(a, targetIntent, "google", "plus"); a.startActivity(Intent.createChooser(targetIntent, "")); }// w ww. j av a 2 s.com public static boolean defineAppToLaunch(Context c, Intent targetIntent, String... keywords) { PackageManager pm = c.getApplicationContext().getPackageManager(); List<ResolveInfo> activityList = pm.queryIntentActivities( targetIntent, 0); for (final ResolveInfo app : activityList) { if (containsAll(keywords, app)) { final ActivityInfo activity = app.activityInfo; final ComponentName name = new ComponentName( activity.applicationInfo.packageName, activity.name); targetIntent.setComponent(name); return true; } } return false; } private static boolean containsAll(String[] keywords, final ResolveInfo app) { for (String keyword : keywords) { if (!app.activityInfo.packageName.contains(keyword)) { return false; } } return true; } }