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:edu.stanford.mobisocial.dungbeetle.feed.objects.InviteToWebSessionObj.java

public void handleDirectMessage(Context context, Contact from, JSONObject obj) {
    String arg = obj.optString(ARG);
    Intent launch = new Intent();
    launch.setAction(Intent.ACTION_MAIN);
    launch.addCategory(Intent.CATEGORY_LAUNCHER);
    launch.putExtra("android.intent.extra.APPLICATION_ARGUMENT", arg);
    launch.putExtra("creator", false);
    launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    String webUrl = obj.optString(WEB_URL);
    launch.setData(Uri.parse(webUrl));/*  www. j a va 2s.co  m*/
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launch,
            PendingIntent.FLAG_CANCEL_CURRENT);
    (new PresenceAwareNotify(context)).notify("New Invitation", "Invitation received",
            "Click to launch application.", contentIntent);
}

From source file:ru.touchin.templates.TouchinActivity.java

@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Possible work around for market launches. See http://code.google.com/p/android/issues/detail?id=2373
    // for more details. Essentially, the market launches the main activity on top of other activities.
    // we never want this to happen. Instead, we check if we are the root and if not, we finish.
    if (!isTaskRoot() && getIntent().hasCategory(Intent.CATEGORY_LAUNCHER)
            && Intent.ACTION_MAIN.equals(getIntent().getAction())) {
        Lc.e("Finishing activity as it is launcher but not root");
        finish();//from   w w w .j av a  2 s  .co  m
    }
}

From source file:com.dm.material.dashboard.candybar.helpers.RequestHelper.java

@NonNull
public static List<Request> loadMissingApps(@NonNull Context context) {
    List<Request> requests = new ArrayList<>();
    Database database = new Database(context);
    String activities = RequestHelper.loadAppFilter(context);
    PackageManager packageManager = context.getPackageManager();

    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    List<ResolveInfo> installedApps = packageManager.queryIntentActivities(intent,
            PackageManager.GET_RESOLVED_FILTER);
    CandyBarMainActivity.sInstalledAppsCount = installedApps.size();

    try {/*  w w w  .j ava  2  s.  c o m*/
        Collections.sort(installedApps, new ResolveInfo.DisplayNameComparator(packageManager));
    } catch (Exception ignored) {
    }

    for (ResolveInfo app : installedApps) {
        String packageName = app.activityInfo.packageName;
        String activity = packageName + "/" + app.activityInfo.name;

        if (!activities.contains(activity)) {
            String name = LocaleHelper.getOtherAppLocaleName(context, new Locale("en-US"), packageName);
            if (name == null)
                name = app.activityInfo.loadLabel(packageManager).toString();

            boolean requested = database.isRequested(activity);
            requests.add(new Request(name, app.activityInfo.packageName, activity, requested));
        }
    }
    return requests;
}

From source file:org.iota.wallet.helper.NotificationHelper.java

public static void requestNotification(Context context, int image, String title, int id) {

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        createNotificationChannel(context);
    }/*from w  w w . ja v a  2s  . c om*/

    notificationManager = (NotificationManager) context.getApplicationContext()
            .getSystemService(Context.NOTIFICATION_SERVICE);

    Intent notificationIntent = new Intent(context, MainActivity.class);
    notificationIntent.setAction(Constants.ACTION_MAIN);
    notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);

    PendingIntent pendingIntent = PendingIntent.getActivity(context, id, notificationIntent, 0);

    Notification notification = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL)
            .setSmallIcon(image).setColor(ContextCompat.getColor(context, R.color.colorAccent))
            .setContentTitle(title).setProgress(0, 0, true).setContentIntent(pendingIntent).setAutoCancel(false)
            .build();

    notificationManager.notify(id, notification);
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.IMObj.java

public void handleDirectMessage(Context context, Contact from, JSONObject obj) {
    Intent launch = new Intent();
    launch.setAction(Intent.ACTION_MAIN);
    launch.addCategory(Intent.CATEGORY_LAUNCHER);
    launch.setComponent(new ComponentName(context.getPackageName(), HomeActivity.class.getName()));
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launch,
            PendingIntent.FLAG_CANCEL_CURRENT);
    String msg = obj.optString(TEXT);
    (new PresenceAwareNotify(context)).notify("IM from " + from.name, "IM from " + from.name, "\"" + msg + "\"",
            contentIntent);/*w  w w.ja va 2s  .c o m*/
}

From source file:com.ce.skuniv.helpers.Notifications.java

public void displayNotification(String title, String text, boolean Sound, int Id, boolean isPresistant) {
    if (Id == 0) {
        Id = rnd.nextInt();//from w w w .  j av  a 2s.  co m
    }
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_stat_icon).setContentTitle(title).setContentText(text);
    if (Sound)
        mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
    // mBuilder.setOnlyAlertOnce(false);
    mBuilder.setTicker(title + ":" + text);
    mBuilder.setOngoing(isPresistant);
    mBuilder.setAutoCancel(true);

    // Intent notificationIntent = new Intent(context,
    // MainMultiWiiActivity.class);

    Intent notificationIntent = new Intent(context, MainMultiWiiActivity.class);
    // notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // You
    // need this if starting
    // the activity from a service
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);

    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(contentIntent);

    //      mNotificationManager.notify(Id, mBuilder.build());
}

From source file:com.ezio.multiwii.helpers.Notifications.java

public void displayNotification(String title, String text, boolean Sound, int Id, boolean isPresistant) {
    if (Id == 0) {
        Id = rnd.nextInt();/*from   w  w w  . j a va 2s. com*/
    }
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_stat_icon).setContentTitle(title).setContentText(text);
    if (Sound)
        mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
    // mBuilder.setOnlyAlertOnce(false);
    mBuilder.setTicker(title + ":" + text);
    mBuilder.setOngoing(isPresistant);
    mBuilder.setAutoCancel(true);

    // Intent notificationIntent = new Intent(context,
    // MainMultiWiiActivity.class);

    Intent notificationIntent = new Intent(context, MainMultiWiiActivity.class);
    // notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // You
    // need this if starting
    // the activity from a service
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);

    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(contentIntent);

    mNotificationManager.notify(Id, mBuilder.build());
}

From source file:com.codyy.lib.utils.ActivityUtils.java

/**
 * ?launcher activity//  w w  w.  j  a v a 2s  . c  o  m
 *
 * @param context     
 * @param packageName ??
 * @return launcher activity
 */
public static String getLauncherActivity(Context context, String packageName) {
    Intent intent = new Intent(Intent.ACTION_MAIN, null);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    PackageManager pm = context.getPackageManager();
    List<ResolveInfo> infos = pm.queryIntentActivities(intent, 0);
    for (ResolveInfo info : infos) {
        if (info.activityInfo.packageName.equals(packageName)) {
            return info.activityInfo.name;
        }
    }
    return "no " + packageName;
}

From source file:com.android.leanlauncher.AppInfo.java

public static Intent makeLaunchIntent(Context context, LauncherActivityInfoCompat info, UserHandleCompat user) {
    long serialNumber = UserManagerCompat.getInstance(context).getSerialNumberForUser(user);
    return new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER)
            .setComponent(info.getComponentName())
            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
            .putExtra(EXTRA_PROFILE, serialNumber);
}

From source file:de.lespace.apprtc.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received.//from   w ww . j a  v a  2 s  .c  om
*/
private void sendNotification(String message) {
    Intent intent = new Intent(this, ConnectActivity.class);
    // intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, //0 Request code
            intent, PendingIntent.FLAG_UPDATE_CURRENT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_launcher).setContentTitle("GCM Message").setContentText(message)
            .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 // ID of notification
            , notificationBuilder.build());

}