Android examples for Activity:Activity Feature
whether app can Launch the main activity.
//package com.java2s; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.text.TextUtils; public class Main { /**/*from www .j a v a2s . c om*/ * whether app can Launch the main activity. * Return true when can Launch,otherwise return false. * @param context * @param packageName * @return */ public static boolean appCanLaunchTheMainActivity(Context context, String packageName) { boolean canLaunchTheMainActivity = false; do { if ((null == context) || TextUtils.isEmpty(packageName)) { break; } PackageManager pm = context.getPackageManager(); Intent intent = pm.getLaunchIntentForPackage(packageName); canLaunchTheMainActivity = (null == intent) ? (false) : (true); } while (false); return canLaunchTheMainActivity; } }