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.jobsched.content.DemoJobService.java

@Override
public boolean onStartJob(JobParameters params) {
    NotificationCompat.Builder b = new NotificationCompat.Builder(this).setAutoCancel(true)
            .setDefaults(Notification.DEFAULT_ALL).setContentTitle("You added a contact!")
            .setSmallIcon(android.R.drawable.stat_notify_more);

    NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    mgr.notify(NOTIFY_ID, b.build());/*w w  w  . j  av a 2  s .  c  o  m*/

    return (false);
}

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

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

    b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL)
            .setContentTitle(getString(R.string.download_complete)).setContentText(getString(R.string.fun))
            .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS))
            .setSmallIcon(android.R.drawable.stat_sys_download_done)
            .setTicker(getString(R.string.download_complete)).setPriority(Notification.PRIORITY_HIGH)
            .setLocalOnly(true).addAction(android.R.drawable.ic_media_play, getString(R.string.play),
                    buildPendingIntent(Settings.ACTION_SETTINGS));

    return (b);// ww  w  .  ja  v  a2s . co m
}

From source file:org.gluu.oxpush2.app.PushNotificationService.java

private void sendNotification(Intent intent, String title, String body) {
    Context context = getBaseContext();
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(title).setAutoCancel(true);

    if (Utils.isNotEmpty(body)) {
        builder.setContentText(body);/*from  www  .j a  va  2  s  .co  m*/
    }

    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(contentIntent);

    builder.setDefaults(Notification.DEFAULT_ALL);

    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(MainActivity.MESSAGE_NOTIFICATION_ID, builder.build());
}

From source file:com.parse.ParsePushUnityHelper.java

/**
 * A helper method that provides default behavior for handling ParsePushNotificationReceived.
 *//*from   w ww  .  j  ava2 s.  c  om*/
public static void handleParsePushNotificationReceived(Context context, String pushPayloadString) {
    try {
        JSONObject pushData = new JSONObject(pushPayloadString);

        if (pushData == null || (!pushData.has("alert") && !pushData.has("title"))) {
            return;
        }

        ManifestInfo info = new ManifestInfo(context);
        String title = pushData.optString("title", info.getDisplayName());
        String alert = pushData.optString("alert", "Notification received.");
        String tickerText = title + ": " + alert;

        Random random = new Random();
        int contentIntentRequestCode = random.nextInt();

        Intent activityIntent = info.getLauncherIntent();
        PendingIntent pContentIntent = PendingIntent.getActivity(context, contentIntentRequestCode,
                activityIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setContentTitle(title)
                .setContentText(alert).setTicker(tickerText).setSmallIcon(info.getPushIconId())
                .setContentIntent(pContentIntent).setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL);

        Notification notification = builder.build();
        NotificationManager manager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        int notificationId = (int) System.currentTimeMillis();

        try {
            manager.notify(notificationId, notification);
        } catch (SecurityException se) {
            // Some phones throw exception for unapproved vibration.
            notification.defaults = Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND;
            manager.notify(notificationId, notification);
        }
    } catch (JSONException e) {
        // Do nothing.
    }
}

From source file:net.nym.napply.library.utils.Notify.java

/**
 * Displays a notification in the notification area of the UI
 * @param context Context from which to create the notification
 * @param messageString The string to display to the user as a message
 * @param smallIconId drawable id//www  .j  a  v a  2 s . co  m
 * @param intent The intent which will start the activity when the user clicks the notification
 * @param notificationTitle The resource reference to the notification title
 * @return messageID
 */
public static int notifcation(Context context, String messageString, int smallIconId, Intent intent,
        int notificationTitle) {

    //Get the notification manage which we will use to display the notification
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);

    Calendar.getInstance().getTime().toString();

    long when = System.currentTimeMillis();

    //get the notification title from the application's strings.xml file
    CharSequence contentTitle = context.getString(notificationTitle);

    //the message that will be displayed as the ticker
    String ticker = contentTitle + " " + messageString;

    //build the pending intent that will start the appropriate activity
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 3, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    //build the notification
    Builder notificationCompat = new Builder(context);
    notificationCompat.setAutoCancel(true).setContentTitle(contentTitle).setContentIntent(pendingIntent)
            .setContentText(messageString).setTicker(ticker).setWhen(when).setSmallIcon(smallIconId)

    ;

    Notification notification = notificationCompat.build();
    //    notification.defaults |= Notification.DEFAULT_ALL;
    notification.defaults = Notification.DEFAULT_ALL;
    //display the notification
    mNotificationManager.notify(MessageID, notification);
    return MessageID++;

}

From source file:com.gerolab.sdksample.SleepStateReceiver.java

public void onReceive(Context context, Intent intent) {
    long startTime = intent.getLongExtra(GeroAccelerometerService.EXTRA_SLEEP_START_TIME, 0);
    long endTime = intent.getLongExtra(GeroAccelerometerService.EXTRA_SLEEP_END_TIME, 0);
    int deltaMinutes = (int) ((endTime - startTime) / 60);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setSmallIcon(android.R.drawable.stat_notify_sync)
            .setContentTitle(context.getString(R.string.label_sleep_notification)).setContentText(
                    String.format(context.getString(R.string.label_sleep_notification_content, deltaMinutes)));
    Intent resultIntent = new Intent(context, LoginActivity.class);
    PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    mBuilder.setContentIntent(resultPendingIntent);
    mBuilder.setDefaults(Notification.DEFAULT_ALL);
    mBuilder.setAutoCancel(true);/*from  ww  w.  j a  v a  2  s. c o  m*/
    NotificationManager mNotificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(0, mBuilder.build());
}

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

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

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

    return (b);//w ww.jav a  2  s  .  co  m
}

From source file:com.bccs.bsecure.MessageReceivedNotification.java

/**
 * Shows the notification, or updates a previously shown notification of
 * this type, with the given parameters.
 * <p>/*from  ww w .  j  a va  2  s . co  m*/
 * Customize this method's arguments to present relevant content in
 * the notification.
 * <p>
 * Customize the contents of this method to tweak the behavior and
 * presentation of message received notifications. Make
 * sure to follow the
 * <a href="https://developer.android.com/design/patterns/notifications.html">
 * Notification design guidelines</a> when doing so.
 *
 * @see #cancel(Context)
 */
public static void notify(final Context context, final String title, final String body) {
    final Resources res = context.getResources();

    // This image is used as the notification's large icon (thumbnail).
    // Remove this if your notification has no relevant thumbnail.
    final Bitmap picture = BitmapFactory.decodeResource(res, R.drawable.ic_security_black_48dp);

    final String text = body;
    //Intent conversationIntent = new Intent("com.bccs.bsecure.recentconversation");
    Intent conversationIntent = new Intent(context, Conversation.class);

    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context)

            // Set appropriate defaults for the notification light, sound,
            // and vibration.
            .setDefaults(Notification.DEFAULT_ALL)

            // Set required fields, including the small icon, the
            // notification title, and text.
            .setSmallIcon(R.drawable.ic_security_black_48dp).setContentTitle(title).setContentText(text)

            // All fields below this line are optional.

            // Use a default priority (recognized on devices running Android
            // 4.1 or later)
            .setPriority(NotificationCompat.PRIORITY_DEFAULT)

            // Provide a large icon, shown with the notification in the
            // notification drawer on devices running Android 3.0 or later.
            .setLargeIcon(picture)

            // If this notification relates to a past or upcoming event, you
            // should set the relevant time information using the setWhen
            // method below. If this call is omitted, the notification's
            // timestamp will by set to the time at which it was shown.
            // Call setWhen if this notification relates to a past or
            // upcoming event. The sole argument to this method should be
            // the notification timestamp in milliseconds.
            //.setWhen(...)

            // Set the pending intent to be initiated when the user touches
            // the notification.
            .setContentIntent(PendingIntent.getActivity(context, 0, conversationIntent,
                    PendingIntent.FLAG_UPDATE_CURRENT))

            // Show expanded text content on devices running Android 4.1 or
            // later.
            .setStyle(new NotificationCompat.BigTextStyle().bigText(text).setBigContentTitle(title)
                    .setSummaryText(body))

            // Automatically dismiss the notification when it is touched.
            .setAutoCancel(true);

    notify(context, builder.build());
}

From source file:net.nym.utilslibrary.utils.Notify.java

/**
 * Displays a notification in the notification area of the UI
 * @param context Context from which to create the notification
 * @param messageString The string to display to the user as a message
 * @param smallIconId drawable id//  w  w  w  .ja  v a2s  .  co m
 * @param intent The intent which will start the activity when the user clicks the notification
 * @param notificationTitle The resource reference to the notification title
 * @return messageID
 */
public static int notifcation(Context context, String notificationTitle, String messageString, int smallIconId,
        Intent intent, int messageID) {

    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns);

    long when = System.currentTimeMillis();

    //get the notification title from the application's strings.xml file
    CharSequence contentTitle = notificationTitle;

    //the message that will be displayed as the ticker
    String ticker = contentTitle + " " + messageString;

    //build the pending intent that will start the appropriate activity
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 3, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    //build the notification
    Builder notificationCompat = new Builder(context);
    notificationCompat.setAutoCancel(true).setContentTitle(contentTitle).setContentIntent(pendingIntent)
            .setContentText(messageString).setTicker(ticker).setWhen(when).setSmallIcon(smallIconId)
            .setDefaults(Notification.DEFAULT_ALL);

    Notification notification = notificationCompat.build();
    //display the notification
    mNotificationManager.notify(messageID, notification);
    return messageID;

}

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

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

    b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL)
            .setContentTitle(getString(R.string.download_complete)).setContentText(getString(R.string.fun))
            .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS))
            .setSmallIcon(android.R.drawable.stat_sys_download_done)
            .setTicker(getString(R.string.download_complete)).addAction(android.R.drawable.ic_media_play,
                    getString(R.string.play), buildPendingIntent(Settings.ACTION_SETTINGS));

    return (b);/*  ww  w  .j a va 2s.c o  m*/
}