Example usage for android.content Intent CATEGORY_LAUNCHER

List of usage examples for android.content Intent CATEGORY_LAUNCHER

Introduction

In this page you can find the example usage for android.content Intent CATEGORY_LAUNCHER.

Prototype

String CATEGORY_LAUNCHER

To view the source code for android.content Intent CATEGORY_LAUNCHER.

Click Source Link

Document

Should be displayed in the top-level launcher.

Usage

From source file:Main.java

public static Intent createLaunchIntent(ComponentName componentName) {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setComponent(componentName);/*w  w  w  .ja  v  a  2 s  . c  om*/
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    return intent;
}

From source file:Main.java

public static void takeMyselfToForeground(Context context, Class launcher) {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setClass(context, launcher);//from w w  w. j  ava2s.c om
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    context.startActivity(intent);
}

From source file:Main.java

public static List<ResolveInfo> getAllApp(Context context) {
    Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    return context.getPackageManager().queryIntentActivities(mainIntent, 0);
}

From source file:Main.java

public static String getLActivityName(Context context) {
    Intent intent = new Intent(Intent.ACTION_MAIN, null);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);

    List<ResolveInfo> resolvInfos = context.getPackageManager().queryIntentActivities(intent, 0);

    String launcherActivityName = "";
    for (int i = 0; i < resolvInfos.size(); i++) {
        launcherActivityName = resolvInfos.get(i).activityInfo.name;
    }/*  w  ww .  j  a v  a2s.c om*/

    return launcherActivityName;
}

From source file:Main.java

public static List<ResolveInfo> getInstalledAppsByActionMainIntent(Context context) {
    final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    return context.getPackageManager().queryIntentActivities(mainIntent, 0);
}

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   w  w w . j a va 2  s.  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

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);//from  w w w . j  a v  a  2 s.  com
    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);//from   w  w  w.  j a  v a 2 s  .  c  om
    List<ResolveInfo> infoList = context.getPackageManager().queryIntentActivities(mainIntent, 0);
    if (infoList.isEmpty()) {
        return false;
    } else {
        return true;
    }
}

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

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);
}