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:org.hansel.myAlert.LocationManagement.java

private void showNotification() {
    Intent i = new Intent(this, MainActivity.class);
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    i.addCategory(Intent.CATEGORY_LAUNCHER);

    PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_launcher).setContentTitle(getResources().getString(R.string.app_name))
            .setContentText("Hansel Running").setContentIntent(pi);

    Notification notif = mBuilder.build();
    notif.flags = Notification.FLAG_NO_CLEAR;
    startForeground(1337, notif);/*from www . j a v  a  2  s . c om*/
}

From source file:cc.flydev.launcher.InstallShortcutReceiver.java

private static ShortcutInfo getShortcutInfo(Context context, Intent data, Intent launchIntent) {
    if (launchIntent.getAction() == null) {
        launchIntent.setAction(Intent.ACTION_VIEW);
    } else if (launchIntent.getAction().equals(Intent.ACTION_MAIN) && launchIntent.getCategories() != null
            && launchIntent.getCategories().contains(Intent.CATEGORY_LAUNCHER)) {
        launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    }/* w  w w . j  a va  2 s  .c om*/
    LauncherAppState app = LauncherAppState.getInstance();
    return app.getModel().infoFromShortcutIntent(context, data, null);
}

From source file:passenger.view.activity.LoginActivity.java

private void registerSuccess() {

    LoginActivity.this.sendBroadcast(new Intent(ACTION_REGISTER));

    Intent serviceIntent = new Intent(self, MainService.class);
    serviceIntent.setAction(EasyTaxiCmd.START_MAINSERVICE);
    startService(serviceIntent);// w  w w  .  java  2 s . c  o m

    if (type == 1) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        ComponentName cn = new ComponentName(pkg, pkg + "." + className);
        intent.setComponent(cn);
        self.startActivity(intent);
    }

    if (type == 2) {
        Intent intent = new Intent(self, MyMainActivity.class);
        self.startActivity(intent);
    }
    // ETApp.getInstance().setLogin(true);
    self.finish();
    // finish();
    // ?????
    Intent alarmIntent = new Intent(self, AlarmClockBookService.class);
    startService(alarmIntent);
}

From source file:com.android.launcher3.widget.DigitalAppWidgetProvider.java

private void updateClock(Context context, AppWidgetManager appWidgetManager, int appWidgetId, float ratio) {
    RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.digital_appwidget);

    // Launch setinngs when clicking on the time in the widget only if not a lock screen widget
    Bundle newOptions = appWidgetManager.getAppWidgetOptions(appWidgetId);
    if (newOptions != null && newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY,
            -1) != AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD) {
        Intent mIntent = new Intent(Intent.ACTION_MAIN);
        mIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        ComponentName component = new ComponentName("com.android.settings", "com.android.settings.Settings");
        mIntent.setComponent(component);
        widget.setOnClickPendingIntent(R.id.digital_appwidget,
                PendingIntent.getActivity(context, 0, mIntent, 0));
    }//from   www . j av  a  2s.  c om

    //cg sai.pan begin
    refreshWifiStatus(context, widget);
    refreshBtStatus(context, widget);
    refreshAirplaneStatus(context, widget,
            Settings.Global.getInt(context.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) != 0);
    mLocationManager = (LocationManager) context.getSystemService(context.LOCATION_SERVICE);
    refreshGpsStatus(context, widget, mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER));
    //refreshDataStatus(context, widget, Settings.Global.getInt(context.getContentResolver(), Settings.Global.MOBILE_DATA, 0) != 0);
    requestLocation(context);
    //cg sai.pan end

    // SPRD for bug421127 add am/pm for widget
    WidgetUtils.setTimeFormat(widget, (int) context.getResources().getDimension(R.dimen.widget_label_font_size),
            R.id.the_clock);
    WidgetUtils.setClockSize(context, widget, ratio);

    // Set today's date format
    CharSequence dateFormat = DateFormat.getBestDateTimePattern(Locale.getDefault(),
            context.getString(R.string.abbrev_wday_month_day_no_year));
    widget.setCharSequence(R.id.date, "setFormat12Hour", dateFormat);
    widget.setCharSequence(R.id.date, "setFormat24Hour", dateFormat);

    appWidgetManager.updateAppWidget(appWidgetId, widget);
}

From source file:com.trellmor.berrytubechat.ChatActivity.java

private void loadPreferences() {
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    try {/*from   w  w w .  ja v a 2  s  .  co m*/
        mScrollback = Integer.parseInt(settings.getString(MainActivity.KEY_SCROLLBACK, "100"));
    } catch (NumberFormatException e) {
        mScrollback = 100;
    }

    if (mScrollback <= 0)
        mScrollback = 100;

    if (mBinder != null)
        mBinder.getService().setChatMsgBufferSize(mScrollback);

    try {
        mFlair = Integer.parseInt(settings.getString(MainActivity.KEY_FLAIR, "0"));
    } catch (NumberFormatException e) {
        mFlair = 0;
    }

    if (settings.getBoolean(MainActivity.KEY_SQUEE, false)) {
        mNotification = new NotificationCompat.Builder(this);
        mNotification.setSmallIcon(R.drawable.ic_stat_notify_chat);
        mNotification.setLights(0xFF0000FF, 100, 2000);
        mNotification.setAutoCancel(true);

        Intent intent = new Intent(this, ChatActivity.class);
        intent.putExtra(MainActivity.KEY_USERNAME, mUsername);
        intent.putExtra(MainActivity.KEY_PASSWORD, mPassword);
        intent.setAction(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP
                | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY);

        mNotification.setContentIntent(
                PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
        String squee = settings.getString(MainActivity.KEY_SQUEE_RINGTONE, "");
        if (!"".equals(squee)) {
            mNotification.setSound(Uri.parse(squee), AudioManager.STREAM_NOTIFICATION);
        }
        if (settings.getBoolean(MainActivity.KEY_SQUEE_VIBRATE, false)) {
            mNotification.setVibrate(new long[] { 0, 100 });
        }
    } else {
        mNotification = null;
    }

    boolean showVideo = settings.getBoolean(MainActivity.KEY_VIDEO, false);
    if (showVideo != mShowVideo) {
        // If the value has changed, act on it
        if (showVideo) {
            if (!mFirstPrefLoad) {
                Toast.makeText(this, R.string.toast_video_enabled, Toast.LENGTH_LONG).show();
            }
        } else {
            mBinder.getService().disableVideoMessages();
            setTextVideoVisible(false);
        }
    }
    mShowVideo = showVideo;

    mShowDrinkCount = settings.getBoolean(MainActivity.KEY_DRINKCOUNT, true);
    mPopupPoll = settings.getBoolean(MainActivity.KEY_POPUP_POLL, false);
    updateDrinkCount();

    mFirstPrefLoad = false;
}

From source file:net.ustyugov.jtalk.Notify.java

public static void imgurFileProgress(Status status, String text) {
    JTalkService service = JTalkService.getInstance();
    Intent i = new Intent(service, RosterActivity.class);
    i.setAction(Intent.ACTION_MAIN);//from ww  w .  j a  va  2  s.c o m
    i.addCategory(Intent.CATEGORY_LAUNCHER);
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent contentIntent = PendingIntent.getActivity(service, 0, i, 0);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(service);
    mBuilder.setContentTitle(service.getString(R.string.SendPhoto));
    mBuilder.setContentText(text);
    mBuilder.setContentIntent(contentIntent);
    mBuilder.setProgress(0, 0, true);

    if (status == Status.in_progress) {
        mBuilder.setSmallIcon(android.R.drawable.stat_sys_upload);
        mBuilder.setTicker(service.getString(R.string.SendPhoto));
    } else if (status == Status.error) {
        mBuilder.setSmallIcon(android.R.drawable.stat_sys_warning);
        mBuilder.setTicker(service.getString(R.string.Error));
        mBuilder.setAutoCancel(true);
    }

    NotificationManager mng = (NotificationManager) service.getSystemService(Context.NOTIFICATION_SERVICE);
    mng.notify(NOTIFICATION_IMGUR, mBuilder.build());
}

From source file:com.androzic.location.LocationService.java

private Notification getNotification() {
    int msgId = R.string.notif_loc_started;
    int ntfId = R.drawable.ic_stat_locating;
    if (trackingEnabled) {
        msgId = R.string.notif_trk_started;
        ntfId = R.drawable.ic_stat_tracking;
    }/*w w  w  . j a  v a  2 s .  c om*/
    if (gpsStatus != LocationService.GPS_OK) {
        msgId = R.string.notif_loc_waiting;
        ntfId = R.drawable.ic_stat_waiting;
    }
    if (gpsStatus == LocationService.GPS_OFF) {
        ntfId = R.drawable.ic_stat_off;
    }
    if (errorTime > 0) {
        msgId = R.string.notif_trk_failure;
        ntfId = R.drawable.ic_stat_failure;
    }

    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setWhen(errorTime);
    builder.setSmallIcon(ntfId);
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setComponent(new ComponentName(getApplicationContext(), Splash.class));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    PendingIntent contentIntent = PendingIntent.getActivity(this, NOTIFICATION_ID, intent, 0);
    builder.setContentIntent(contentIntent);
    builder.setContentTitle(getText(R.string.notif_loc_short));
    if (errorTime > 0 && DEBUG_ERRORS)
        builder.setContentText(errorMsg);
    else
        builder.setContentText(getText(msgId));
    builder.setOngoing(true);

    Notification notification = builder.getNotification();
    return notification;
}

From source file:com.brayanarias.alarmproject.activity.AlarmScreenActivity.java

private void sendNotification(String msg) {
    alarmNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    String title = getString(R.string.title_activity_main);
    Intent intent = new Intent(this, AlarmScreenActivity.class);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    Bitmap bitmap = ((BitmapDrawable) getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap();
    NotificationCompat.Builder alarmNotificationBuilder = new NotificationCompat.Builder(this)
            .setContentTitle(title).setSmallIcon(R.drawable.ic_fab_alarm).setLargeIcon(bitmap)
            .setCategory(Notification.CATEGORY_ALARM)
            .setColor(ContextCompat.getColor(getBaseContext(), R.color.colorAccent))
            .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg).setOngoing(true)
            .setContentIntent(pendingIntent);
    alarmNotificationManager.notify(1503, alarmNotificationBuilder.build());
}

From source file:org.zywx.wbpalmstar.engine.universalex.EUExWidget.java

private String getMainActivity(String pkgName) {
    String className = null;//from   w  w  w. j  a  v a2s .  com
    PackageInfo pi = null;
    try {
        pi = mContext.getPackageManager().getPackageInfo(pkgName, 0);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    if (pi == null)
        return null;

    Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
    resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    resolveIntent.setPackage(pi.packageName);

    List<ResolveInfo> apps = mContext.getPackageManager().queryIntentActivities(resolveIntent, 0);
    if (apps == null || apps.size() == 0)
        return null;

    ResolveInfo ri = apps.iterator().next();
    if (ri != null) {
        className = ri.activityInfo.name;
    }
    return className;
}

From source file:nl.vanvianen.android.gcm.GCMIntentService.java

@Override
@SuppressWarnings("unchecked")
protected void onMessage(Context context, Intent intent) {
    Log.d(LCAT, "Push notification received");

    boolean isTopic = false;

    HashMap<String, Object> data = new HashMap<String, Object>();
    for (String key : intent.getExtras().keySet()) {
        Object value = intent.getExtras().get(key);
        Log.d(LCAT, "Message key: \"" + key + "\" value: \"" + value + "\"");

        if (key.equals("from") && value instanceof String && ((String) value).startsWith("/topics/")) {
            isTopic = true;//from  www  .  j av a2 s  .  c  o  m
        }

        String eventKey = key.startsWith("data.") ? key.substring(5) : key;
        data.put(eventKey, intent.getExtras().get(key));

        if (value instanceof String && ((String) value).startsWith("{")) {
            Log.d(LCAT, "Parsing JSON string...");
            try {
                JSONObject json = new JSONObject((String) value);

                Iterator<String> keys = json.keys();
                while (keys.hasNext()) {
                    String jKey = keys.next();
                    String jValue = json.getString(jKey);
                    Log.d(LCAT, "JSON key: \"" + jKey + "\" value: \"" + jValue + "\"");

                    data.put(jKey, jValue);
                }
            } catch (JSONException ex) {
                Log.d(LCAT, "JSON error: " + ex.getMessage());
            }
        }
    }

    /* Store data to be retrieved when resuming app as a JSON object, serialized as a String, otherwise
     * Ti.App.Properties.getString(GCMModule.LAST_DATA) doesn't work. */
    JSONObject json = new JSONObject(data);
    TiApplication.getInstance().getAppProperties().setString(GCMModule.LAST_DATA, json.toString());

    /* Get settings from notification object */
    int smallIcon = 0;
    int largeIcon = 0;
    String sound = null;
    boolean vibrate = false;
    boolean insistent = false;
    String group = null;
    boolean localOnly = true;
    int priority = 0;
    boolean bigText = false;
    int notificationId = 1;

    Integer ledOn = null;
    Integer ledOff = null;

    String titleKey = DEFAULT_TITLE_KEY;
    String messageKey = DEFAULT_MESSAGE_KEY;
    String tickerKey = DEFAULT_TICKER_KEY;
    String title = null;
    String message = null;
    String ticker = null;

    boolean backgroundOnly = false;

    Map<String, Object> notificationSettings = new Gson().fromJson(
            TiApplication.getInstance().getAppProperties().getString(GCMModule.NOTIFICATION_SETTINGS, null),
            Map.class);
    if (notificationSettings != null) {
        if (notificationSettings.get("smallIcon") instanceof String) {
            smallIcon = getResource("drawable", (String) notificationSettings.get("smallIcon"));
        } else {
            Log.e(LCAT, "Invalid setting smallIcon, should be String");
        }

        if (notificationSettings.get("largeIcon") instanceof String) {
            largeIcon = getResource("drawable", (String) notificationSettings.get("largeIcon"));
        } else {
            Log.e(LCAT, "Invalid setting largeIcon, should be String");
        }

        if (notificationSettings.get("sound") != null) {
            if (notificationSettings.get("sound") instanceof String) {
                sound = (String) notificationSettings.get("sound");
            } else {
                Log.e(LCAT, "Invalid setting sound, should be String");
            }
        }

        if (notificationSettings.get("vibrate") != null) {
            if (notificationSettings.get("vibrate") instanceof Boolean) {
                vibrate = (Boolean) notificationSettings.get("vibrate");
            } else {
                Log.e(LCAT, "Invalid setting vibrate, should be Boolean");
            }
        }

        if (notificationSettings.get("insistent") != null) {
            if (notificationSettings.get("insistent") instanceof Boolean) {
                insistent = (Boolean) notificationSettings.get("insistent");
            } else {
                Log.e(LCAT, "Invalid setting insistent, should be Boolean");
            }
        }

        if (notificationSettings.get("group") != null) {
            if (notificationSettings.get("group") instanceof String) {
                group = (String) notificationSettings.get("group");
            } else {
                Log.e(LCAT, "Invalid setting group, should be String");
            }
        }

        if (notificationSettings.get("localOnly") != null) {
            if (notificationSettings.get("localOnly") instanceof Boolean) {
                localOnly = (Boolean) notificationSettings.get("localOnly");
            } else {
                Log.e(LCAT, "Invalid setting localOnly, should be Boolean");
            }
        }

        if (notificationSettings.get("priority") != null) {
            if (notificationSettings.get("priority") instanceof Integer) {
                priority = (Integer) notificationSettings.get("priority");
            } else if (notificationSettings.get("priority") instanceof Double) {
                priority = ((Double) notificationSettings.get("priority")).intValue();
            } else {
                Log.e(LCAT,
                        "Invalid setting priority, should be an integer, between PRIORITY_MIN ("
                                + NotificationCompat.PRIORITY_MIN + ") and PRIORITY_MAX ("
                                + NotificationCompat.PRIORITY_MAX + ")");
            }
        }

        if (notificationSettings.get("bigText") != null) {
            if (notificationSettings.get("bigText") instanceof Boolean) {
                bigText = (Boolean) notificationSettings.get("bigText");
            } else {
                Log.e(LCAT, "Invalid setting bigText, should be Boolean");
            }
        }

        if (notificationSettings.get("titleKey") != null) {
            if (notificationSettings.get("titleKey") instanceof String) {
                titleKey = (String) notificationSettings.get("titleKey");
            } else {
                Log.e(LCAT, "Invalid setting titleKey, should be String");
            }
        }

        if (notificationSettings.get("messageKey") != null) {
            if (notificationSettings.get("messageKey") instanceof String) {
                messageKey = (String) notificationSettings.get("messageKey");
            } else {
                Log.e(LCAT, "Invalid setting messageKey, should be String");
            }
        }

        if (notificationSettings.get("tickerKey") != null) {
            if (notificationSettings.get("tickerKey") instanceof String) {
                tickerKey = (String) notificationSettings.get("tickerKey");
            } else {
                Log.e(LCAT, "Invalid setting tickerKey, should be String");
            }
        }

        if (notificationSettings.get("title") != null) {
            if (notificationSettings.get("title") instanceof String) {
                title = (String) notificationSettings.get("title");
            } else {
                Log.e(LCAT, "Invalid setting title, should be String");
            }
        }

        if (notificationSettings.get("message") != null) {
            if (notificationSettings.get("message") instanceof String) {
                message = (String) notificationSettings.get("message");
            } else {
                Log.e(LCAT, "Invalid setting message, should be String");
            }
        }

        if (notificationSettings.get("ticker") != null) {
            if (notificationSettings.get("ticker") instanceof String) {
                ticker = (String) notificationSettings.get("ticker");
            } else {
                Log.e(LCAT, "Invalid setting ticker, should be String");
            }
        }

        if (notificationSettings.get("ledOn") != null) {
            if (notificationSettings.get("ledOn") instanceof Integer) {
                ledOn = (Integer) notificationSettings.get("ledOn");
                if (ledOn < 0) {
                    Log.e(LCAT, "Invalid setting ledOn, should be positive");
                    ledOn = null;
                }
            } else {
                Log.e(LCAT, "Invalid setting ledOn, should be Integer");
            }
        }

        if (notificationSettings.get("ledOff") != null) {
            if (notificationSettings.get("ledOff") instanceof Integer) {
                ledOff = (Integer) notificationSettings.get("ledOff");
                if (ledOff < 0) {
                    Log.e(LCAT, "Invalid setting ledOff, should be positive");
                    ledOff = null;
                }
            } else {
                Log.e(LCAT, "Invalid setting ledOff, should be Integer");
            }
        }

        if (notificationSettings.get("backgroundOnly") != null) {
            if (notificationSettings.get("backgroundOnly") instanceof Boolean) {
                backgroundOnly = (Boolean) notificationSettings.get("backgroundOnly");
            } else {
                Log.e(LCAT, "Invalid setting backgroundOnly, should be Boolean");
            }
        }

        if (notificationSettings.get("notificationId") != null) {
            if (notificationSettings.get("notificationId") instanceof Integer) {
                notificationId = (Integer) notificationSettings.get("notificationId");
            } else {
                Log.e(LCAT, "Invalid setting notificationId, should be Integer");
            }
        }

    } else {
        Log.d(LCAT, "No notification settings found");
    }

    /* If icon not found, default to appicon */
    if (smallIcon == 0) {
        smallIcon = getResource("drawable", "appicon");
    }

    /* If large icon not found, default to icon */
    if (largeIcon == 0) {
        largeIcon = smallIcon;
    }

    /* Create intent to (re)start the app's root activity */
    String pkg = TiApplication.getInstance().getApplicationContext().getPackageName();
    Intent launcherIntent = TiApplication.getInstance().getApplicationContext().getPackageManager()
            .getLaunchIntentForPackage(pkg);
    launcherIntent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER);

    /* Grab notification content from data according to provided keys if not already set */
    if (title == null && titleKey != null) {
        title = (String) data.get(titleKey);
    }
    if (message == null && messageKey != null) {
        message = (String) data.get(messageKey);
    }
    if (ticker == null && tickerKey != null) {
        ticker = (String) data.get(tickerKey);
    }

    Log.i(LCAT, "Title: " + title);
    Log.i(LCAT, "Message: " + message);
    Log.i(LCAT, "Ticker: " + ticker);

    /* Check for app state */
    if (GCMModule.getInstance() != null) {
        /* Send data to app */
        if (isTopic) {
            GCMModule.getInstance().sendTopicMessage(data);
        } else {
            GCMModule.getInstance().sendMessage(data);
        }
        /* Do not create notification if backgroundOnly and app is in foreground */
        if (backgroundOnly && GCMModule.getInstance().isInForeground()) {
            Log.d(LCAT, "Notification received in foreground, no need for notification.");
            return;
        }
    }

    if (message == null) {
        Log.d(LCAT,
                "Message received but no 'message' specified in push notification payload, so will make this silent");
    } else {
        Log.d(LCAT, "Creating notification...");

        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), largeIcon);
        if (bitmap == null) {
            Log.d(LCAT, "No large icon found");
        }

        NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setContentTitle(title)
                .setContentText(message).setTicker(ticker)
                .setContentIntent(
                        PendingIntent.getActivity(this, 0, launcherIntent, PendingIntent.FLAG_ONE_SHOT))
                .setSmallIcon(smallIcon).setLargeIcon(bitmap);

        /* Name of group to group similar notifications together, can also be set in the push notification payload */
        if (data.get("group") != null) {
            group = (String) data.get("group");
        }
        if (group != null) {
            builder.setGroup(group);
        }
        Log.i(LCAT, "Group: " + group);

        /* Whether notification should be for this device only or bridged to other devices, can also be set in the push notification payload */
        if (data.get("localOnly") != null) {
            localOnly = Boolean.valueOf((String) data.get("localOnly"));
        }
        builder.setLocalOnly(localOnly);
        Log.i(LCAT, "LocalOnly: " + localOnly);

        /* Specify notification priority, can also be set in the push notification payload */
        if (data.get("priority") != null) {
            priority = Integer.parseInt((String) data.get("priority"));
        }
        if (priority >= NotificationCompat.PRIORITY_MIN && priority <= NotificationCompat.PRIORITY_MAX) {
            builder.setPriority(priority);
            Log.i(LCAT, "Priority: " + priority);
        } else {
            Log.e(LCAT, "Ignored invalid priority " + priority);
        }

        /* Specify whether bigtext should be used, can also be set in the push notification payload */
        if (data.get("bigText") != null) {
            bigText = Boolean.valueOf((String) data.get("bigText"));
        }
        if (bigText) {
            builder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
        }
        Log.i(LCAT, "bigText: " + bigText);

        Notification notification = builder.build();

        /* Sound, can also be set in the push notification payload */
        if (data.get("sound") != null) {
            Log.d(LCAT, "Sound specified in notification");
            sound = (String) data.get("sound");
        }

        if ("default".equals(sound)) {
            Log.i(LCAT, "Sound: default sound");
            notification.defaults |= Notification.DEFAULT_SOUND;
        } else if (sound != null) {
            Log.i(LCAT, "Sound " + sound);
            notification.sound = Uri.parse("android.resource://" + pkg + "/" + getResource("raw", sound));
        }

        /* Vibrate, can also be set in the push notification payload */
        if (data.get("vibrate") != null) {
            vibrate = Boolean.valueOf((String) data.get("vibrate"));
        }
        if (vibrate) {
            notification.defaults |= Notification.DEFAULT_VIBRATE;
        }
        Log.i(LCAT, "Vibrate: " + vibrate);

        /* Insistent, can also be set in the push notification payload */
        if ("true".equals(data.get("insistent"))) {
            insistent = true;
        }
        if (insistent) {
            notification.flags |= Notification.FLAG_INSISTENT;
        }
        Log.i(LCAT, "Insistent: " + insistent);

        /* notificationId, set in push payload to specify multiple notifications should be shown. If not specified, subsequent notifications "override / overwrite" the older ones */
        if (data.get("notificationId") != null) {
            if (data.get("notificationId") instanceof Integer) {
                notificationId = (Integer) data.get("notificationId");
            } else if (data.get("notificationId") instanceof String) {
                try {
                    notificationId = Integer.parseInt((String) data.get("notificationId"));
                } catch (NumberFormatException ex) {
                    Log.e(LCAT, "Invalid setting notificationId, should be Integer");
                }
            } else {
                Log.e(LCAT, "Invalid setting notificationId, should be Integer");
            }
        }
        Log.i(LCAT, "Notification ID: " + notificationId);

        /* Specify LED flashing */
        if (ledOn != null || ledOff != null) {
            notification.flags |= Notification.FLAG_SHOW_LIGHTS;
            if (ledOn != null) {
                notification.ledOnMS = ledOn;
            }
            if (ledOff != null) {
                notification.ledOffMS = ledOff;
            }
        } else {
            notification.defaults |= Notification.DEFAULT_LIGHTS;
        }

        notification.flags |= Notification.FLAG_AUTO_CANCEL;

        ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(notificationId,
                notification);
    }
}