Example usage for android.app Notification DEFAULT_ALL

List of usage examples for android.app Notification DEFAULT_ALL

Introduction

In this page you can find the example usage for android.app Notification DEFAULT_ALL.

Prototype

int DEFAULT_ALL

To view the source code for android.app Notification DEFAULT_ALL.

Click Source Link

Document

Use all default values (where applicable).

Usage

From source file:com.commonsware.android.stacked.MainActivity.java

private void showWearTwo() {
    NotificationCompat.Builder b = new NotificationCompat.Builder(this);

    b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL)
            .setContentTitle(getString(R.string.another_entry))
            .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS))
            .setSmallIcon(android.R.drawable.stat_sys_download_done)
            .setTicker(getString(R.string.download_complete)).setGroup(GROUP_SAMPLE);

    mgr.notify(NOTIFY_ID3, b.build());/*from   ww w.  ja  va 2s.co  m*/
}

From source file:br.com.atarde.portal.MyFirebaseMessagingService.java

private void sendNotification(String messageBody) {
    Intent intent = new Intent(this, MainActivity.class);

    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

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

    Bitmap rawBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setContentTitle("Portal A Tarde").setContentText(messageBody).setAutoCancel(true)
            .setSound(defaultSoundUri).setContentIntent(pendingIntent).setDefaults(Notification.DEFAULT_ALL)
            .setSmallIcon(R.mipmap.ic_launcher).setLargeIcon(rawBitmap);

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

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

From source file:com.commonsware.android.andcorder.RecorderService.java

private void foregroundify(boolean showRecord) {
    NotificationCompat.Builder b = new NotificationCompat.Builder(this);

    b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL);

    b.setContentTitle(getString(R.string.app_name)).setSmallIcon(R.mipmap.ic_launcher)
            .setTicker(getString(R.string.app_name));

    if (showRecord) {
        b.addAction(R.drawable.ic_videocam_white_24dp, getString(R.string.notify_record),
                buildPendingIntent(ACTION_RECORD));
    } else {/*  ww w . ja va2 s .c  o m*/
        b.addAction(R.drawable.ic_stop_white_24dp, getString(R.string.notify_stop),
                buildPendingIntent(ACTION_STOP));
    }

    b.addAction(R.drawable.ic_eject_white_24dp, getString(R.string.notify_shutdown),
            buildPendingIntent(ACTION_SHUTDOWN));

    if (isForeground) {
        NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

        mgr.notify(NOTIFY_ID, b.build());
    } else {
        startForeground(NOTIFY_ID, b.build());
        isForeground = true;
    }
}

From source file:com.jackie.notifyingUser.PingService.java

private void issueNotification(String msg) {
    // Sets up the Snooze and Dismiss action buttons that will appear in the
    // expanded view of the notification.
    Intent dismissIntent = new Intent(this, PingService.class);
    dismissIntent.setAction(CommonConstants.ACTION_DISMISS);
    PendingIntent piDismiss = PendingIntent.getService(this, 0, dismissIntent, 0);

    Intent snoozeIntent = new Intent(this, PingService.class);
    snoozeIntent.setAction(CommonConstants.ACTION_SNOOZE);
    PendingIntent piSnooze = PendingIntent.getService(this, 0, snoozeIntent, 0);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setSmallIcon(R.drawable.ic_stat_notification);
    builder.setContentTitle(getString(R.string.notification));
    builder.setContentText(getString(R.string.ping));
    builder.setDefaults(Notification.DEFAULT_ALL); // requires VIBRATE permission;

    /*/*w  w  w. j  a  v a  2s .  c om*/
     * Sets the big view "big text" style and supplies the text (the user's reminder message)
     * that will be displayed in the detail area of the expanded notification.
     * these calls are ignored by the support library for pre-5.1 devices.
     */
    builder.setStyle(new NotificationCompat.BigTextStyle().bigText(msg));
    builder.addAction(R.drawable.ic_stat_dismiss, getString(R.string.dismiss), piDismiss);
    builder.addAction(R.drawable.ic_stat_snooze, getString(R.string.snooze), piSnooze);

    /*
     * Clicking the notification itself displays ResultActivity, which provides UI for snoozing
     * or dismissing the notification.
     * This is available through either the normal view or big view.
     */
    Intent resultIntent = new Intent(this, ResultActivity.class);
    resultIntent.putExtra(CommonConstants.EXTRA_MESSAGE, msg);
    resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

    // Because clicking the notification launches a new ("special") activity,
    // there's no need to create an artificial back stack.
    PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0, resultIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    // this sets the pending intent that should be fired when the user clicks the
    // notification. Clicking the notification launches a new activity.
    builder.setContentIntent(resultPendingIntent);
    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    mNotificationManager.notify(CommonConstants.NOTIFICATION_ID, builder.build());
}

From source file:org.linphone.compatibility.ApiTwentyOnePlus.java

public static Notification createSimpleNotification(Context context, String title, String text,
        PendingIntent intent) {//from w ww. j  a  v  a  2s . com
    Notification notif = new NotificationCompat.Builder(context).setContentTitle(title).setContentText(text)
            .setSmallIcon(R.drawable.logo_linphone_57x57).setAutoCancel(true).setContentIntent(intent)
            .setDefaults(Notification.DEFAULT_ALL).setCategory(Notification.CATEGORY_MESSAGE)
            .setVisibility(Notification.VISIBILITY_PRIVATE).setPriority(Notification.PRIORITY_HIGH).build();

    return notif;
}

From source file:com.dvdprime.mobile.android.gcm.command.CommentCommand.java

private void displayNotification(Context context, String message) {
    LOGI(TAG, "Displaying notification: " + message);
    Gcm gcm = GsonUtil.fromJson(message, Gcm.class);
    SystemUtil.launcherBroadcast(DpApp.class, gcm.getCount());
    String targetUrl = null;/*from w ww .ja v  a2s .c  o m*/
    try {
        targetUrl = URLDecoder.decode(gcm.getTargetUrl(), Config.UTF8);
    } catch (UnsupportedEncodingException e) {
    }
    if (PrefUtil.getInstance().getBoolean(PrefKeys.NOTIFICATION_COMMENT, true) && targetUrl != null) {
        ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(0,
                new NotificationCompat.Builder(context).setWhen(System.currentTimeMillis())
                        .setSmallIcon(R.drawable.ic_launcher).setTicker(gcm.getMessage())
                        .setContentTitle(gcm.getMessage()).setContentText(gcm.getTitle())
                        .setContentIntent(PendingIntent.getActivity(context, 0,
                                new Intent(context, DocumentViewActivity.class)
                                        .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
                                                | Intent.FLAG_ACTIVITY_SINGLE_TOP)
                                        .setData(Uri.parse(targetUrl))
                                        .putExtra("targetKey", gcm.getTargetKey()),
                                0))
                        .setDefaults(Notification.DEFAULT_ALL).setAutoCancel(true).build());
    }
}

From source file:com.granita.tasks.notification.NotificationActionUtils.java

public static void sendDueAlarmNotification(Context context, String title, Uri taskUri, int notificationId,
        long dueDate, boolean dueAllDay, String timezone, boolean silent) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);

    String dueString = "";
    if (dueAllDay) {
        dueString = context.getString(R.string.notification_task_due_today);
    } else {// ww w  .j a  va2s.co m
        dueString = context.getString(R.string.notification_task_due_date, new DateFormatter(context)
                .format(makeTime(dueDate, dueAllDay), DateFormatContext.NOTIFICATION_VIEW));
    }

    // build notification
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_notification)
            .setContentTitle(context.getString(R.string.notification_task_due_title, title))
            .setContentText(dueString);

    // dismisses the notification on click
    mBuilder.setAutoCancel(true);

    // set status bar test
    mBuilder.setTicker(title);

    // enable light, sound and vibration
    if (silent) {
        mBuilder.setDefaults(0);
    } else {
        mBuilder.setDefaults(Notification.DEFAULT_ALL);
    }

    // Creates an explicit intent for an Activity in your app
    Intent resultIntent = new Intent(Intent.ACTION_VIEW);
    resultIntent.setData(taskUri);

    // The stack builder object will contain an artificial back stack for the
    // started Activity.
    // This ensures that navigating backward from the Activity leads out of
    // your application to the Home screen.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    // Adds the Intent that starts the Activity to the top of the stack
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    // add actions
    if (android.os.Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
        // delay notification
        mBuilder.addAction(NotificationActionIntentService.getDelay1dAction(context, notificationId, taskUri,
                dueDate, timezone, dueAllDay));

        // complete action
        NotificationAction completeAction = new NotificationAction(
                NotificationActionIntentService.ACTION_COMPLETE, R.string.notification_action_completed,
                notificationId, taskUri, dueDate);
        mBuilder.addAction(NotificationActionIntentService.getCompleteAction(context,
                NotificationActionUtils.getNotificationActionPendingIntent(context, completeAction)));
    }

    // set displayed time
    if (dueAllDay) {
        Time now = new Time();
        now.setToNow();
        now.set(0, 0, 0, now.monthDay, now.month, now.year);
        mBuilder.setWhen(now.toMillis(true));
    } else {
        mBuilder.setWhen(dueDate);
    }

    mBuilder.setContentIntent(resultPendingIntent);
    notificationManager.notify(notificationId, mBuilder.build());
}

From source file:com.dnabuba.tacademy.abuband.GCM.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received./*from   w w  w  . j ava  2s .  c  om*/
 */
private void sendNotification(String message) {
    Intent intent = new Intent(this, IntroActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    //        Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    //        Uri defaultSoundUri= RingtoneManager.getDefaultUri(R.raw.alert_sound);
    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.icon).setContentTitle("").setContentText(message)
            .setAutoCancel(true)
            //                .setVibrate(new long[]{1000, 1000, 1000})
            //                .setSound(defaultSoundUri)
            .setDefaults(Notification.DEFAULT_ALL).setContentIntent(pendingIntent);

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

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

From source file:com.example.android.pingme.PingService.java

private void issueNotification(Intent intent, String msg) {
    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    // Sets up the Snooze and Dismiss action buttons that will appear in the
    // expanded view of the notification.
    Intent dismissIntent = new Intent(this, PingService.class);
    dismissIntent.setAction(CommonConstants.ACTION_DISMISS);
    PendingIntent piDismiss = PendingIntent.getService(this, 0, dismissIntent, 0);

    Intent snoozeIntent = new Intent(this, PingService.class);
    snoozeIntent.setAction(CommonConstants.ACTION_SNOOZE);
    PendingIntent piSnooze = PendingIntent.getService(this, 0, snoozeIntent, 0);

    // Constructs the Builder object.
    builder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_stat_notification)
            .setContentTitle(getString(R.string.notification)).setContentText(getString(R.string.ping))
            .setDefaults(Notification.DEFAULT_ALL) // requires VIBRATE permission
            /*//www  .  j a  va 2  s .  c o m
             * Sets the big view "big text" style and supplies the
             * text (the user's reminder message) that will be displayed
             * in the detail area of the expanded notification.
             * These calls are ignored by the support library for
             * pre-4.1 devices.
             */
            .setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
            .addAction(R.drawable.ic_stat_dismiss, getString(R.string.dismiss), piDismiss)
            .addAction(R.drawable.ic_stat_snooze, getString(R.string.snooze), piSnooze);

    /*
     * Clicking the notification itself displays ResultActivity, which provides
     * UI for snoozing or dismissing the notification.
     * This is available through either the normal view or big view.
     */
    Intent resultIntent = new Intent(this, ResultActivity.class);
    resultIntent.putExtra(CommonConstants.EXTRA_MESSAGE, msg);
    resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

    // Because clicking the notification opens a new ("special") activity, there's
    // no need to create an artificial back stack.
    PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0, resultIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    builder.setContentIntent(resultPendingIntent);
    startTimer(mMillis);
}

From source file:com.commonsware.android.sawmonitor.PackageReceiver.java

private void seeSAW(Context ctxt, String pkg, boolean isReplace) {
    if (hasSAW(ctxt, pkg)) {
        Uri pkgUri = Uri.parse("package:" + pkg);
        Intent manage = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);

        manage.setData(pkgUri);//  w w w  .java  2s .  c o  m

        Intent whitelist = new Intent(ctxt, WhitelistReceiver.class);

        whitelist.setData(pkgUri);

        Intent main = new Intent(ctxt, MainActivity.class);

        main.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);

        NotificationCompat.Builder b = new NotificationCompat.Builder(ctxt);
        String text = String.format(ctxt.getString(R.string.msg_requested),
                isReplace ? ctxt.getString(R.string.msg_upgraded) : ctxt.getString(R.string.msg_installed),
                pkg);

        b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL).setWhen(System.currentTimeMillis())
                .setContentTitle(ctxt.getString(R.string.msg_detected)).setContentText(text)
                .setSmallIcon(android.R.drawable.stat_notify_error)
                .setTicker(ctxt.getString(R.string.msg_detected))
                .setContentIntent(PendingIntent.getActivity(ctxt, 0, manage, PendingIntent.FLAG_UPDATE_CURRENT))
                .addAction(R.drawable.ic_verified_user_24dp, ctxt.getString(R.string.msg_whitelist),
                        PendingIntent.getBroadcast(ctxt, 0, whitelist, 0))
                .addAction(R.drawable.ic_settings_24dp, ctxt.getString(R.string.msg_settings),
                        PendingIntent.getActivity(ctxt, 0, main, 0));

        NotificationManager mgr = (NotificationManager) ctxt.getSystemService(Context.NOTIFICATION_SERVICE);

        mgr.notify(NOTIFY_ID, b.build());
    }
}