List of usage examples for android.content Intent ACTION_MAIN
String ACTION_MAIN
To view the source code for android.content Intent ACTION_MAIN.
Click Source Link
From source file:Main.java
public static ResolveInfo getResolveInfo(PackageManager pm, String packageName) { Intent intent = new Intent(Intent.ACTION_MAIN, null); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setPackage(packageName);//from www . j ava2s . c om List<ResolveInfo> apps = pm.queryIntentActivities(intent, 0); if (apps != null && apps.size() > 0) { return apps.get(0); } return null; }
From source file:Main.java
/** * start home intent/* w w w.j a v a 2 s . c om*/ * * @param context */ public static void startHomeActivity(Context context) { Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME); homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); context.startActivity(homeIntent); }
From source file:Main.java
/** * Minimizes the app// ww w . j a v a 2 s.c o m * @param context the context */ public static void minimizeApp(Context context) { Intent startMain = new Intent(Intent.ACTION_MAIN); startMain.addCategory(Intent.CATEGORY_HOME); startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(startMain); }
From source file:Main.java
public static boolean isSplashOpenedOverNavigationActivity(final Activity act, final Intent intent) { return intent != null && intent.getAction() != null && intent.getAction().equals(Intent.ACTION_MAIN) && !act.isTaskRoot() && intent.hasCategory(Intent.CATEGORY_LAUNCHER); }
From source file:Main.java
public static ArrayList<String> getActivities(Context ctx) { ArrayList<String> result = new ArrayList<String>(); Intent intent = new Intent(Intent.ACTION_MAIN, null); intent.setPackage(ctx.getPackageName()); for (ResolveInfo info : ctx.getPackageManager().queryIntentActivities(intent, 0)) { result.add(info.activityInfo.name); }/*from w w w . ja v a 2s. c o m*/ return result; }
From source file:Main.java
public static boolean openAppActivity(Context context, String packageName, String activityName) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ComponentName cn = new ComponentName(packageName, activityName); intent.setComponent(cn);/* w ww. java2s .c om*/ try { context.startActivity(intent); return true; } catch (ActivityNotFoundException e) { return false; } }
From source file:Main.java
public static boolean isLauncherActivity(Context context, String packageName) { Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); mainIntent.setPackage(packageName);/* w w w . j a v a 2s .com*/ List<ResolveInfo> infoList = context.getPackageManager().queryIntentActivities(mainIntent, 0); if (infoList.isEmpty()) { return false; } else { return true; } }
From source file:Main.java
/** * "Exits" the app to the Home screen".//from ww w . j a va 2 s. c o m * @param context Application context */ public static void exitToHome(final Context context) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:Main.java
public static List<ResolveInfo> loadApps(Context context) { List<ResolveInfo> mApps; Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); mApps = context.getPackageManager().queryIntentActivities(mainIntent, 0); return mApps; }
From source file:Main.java
@NonNull private static String getDefaultLauncher(@NonNull Context context) { final Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME); final ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); return resolveInfo.activityInfo.packageName; }