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.android.dialer.calllog.DefaultVoicemailNotifier.java

/**
 * Determines which ringtone Uri and Notification defaults to use when updating the notification
 * for the given call.//from w ww.j  a v a2s .c om
 */
private Pair<Uri, Integer> getNotificationInfo(@Nullable NewCall callToNotify) {
    Log.v(TAG, "getNotificationInfo");
    if (callToNotify == null) {
        Log.i(TAG, "callToNotify == null");
        return new Pair<>(null, 0);
    }
    PhoneAccountHandle accountHandle = null;
    if (callToNotify.accountComponentName == null || callToNotify.accountId == null) {
        Log.v(TAG, "accountComponentName == null || callToNotify.accountId == null");
        accountHandle = TelecomUtil.getDefaultOutgoingPhoneAccount(mContext, PhoneAccount.SCHEME_TEL);
        if (accountHandle == null) {
            Log.i(TAG, "No default phone account found, using default notification ringtone");
            return new Pair<>(null, Notification.DEFAULT_ALL);
        }

    } else {
        accountHandle = new PhoneAccountHandle(
                ComponentName.unflattenFromString(callToNotify.accountComponentName), callToNotify.accountId);
    }
    if (accountHandle.getComponentName() != null) {
        Log.v(TAG, "PhoneAccountHandle.ComponentInfo:" + accountHandle.getComponentName());
    } else {
        Log.i(TAG, "PhoneAccountHandle.ComponentInfo: null");
    }
    return new Pair<>(TelephonyManagerCompat.getVoicemailRingtoneUri(getTelephonyManager(), accountHandle),
            getNotificationDefaults(accountHandle));
}

From source file:com.snippet.app.NotificationActivity.java

public void onButton7(final View v) {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .setDefaults(Notification.DEFAULT_ALL)
            .setLargeIcon(BitmapFactory.decodeResource(getResources(), android.R.drawable.sym_def_app_icon))
            .setSmallIcon(android.R.drawable.stat_notify_chat).setTicker("I will alert only this time!")
            .setContentTitle("ContentTitle")
            .setContentText("ContentText: Hello world! The quick brown fox jumps over the lazy dog.")
            .setSubText("SubText").setContentInfo("10").setOnlyAlertOnce(true).setAutoCancel(true);
    Intent resultIntent = new Intent(this, NotificationResultActivity.class);
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
    stackBuilder.addParentStack(NotificationResultActivity.class);
    stackBuilder.addNextIntent(resultIntent);
    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setContentIntent(resultPendingIntent);
    notificationManager.notify(7, builder.build());
}

From source file:com.simicart.core.notification.GCMIntentService.java

private void generateNotification(Context context, NotificationEntity notificationData) {
    // Invoking the default notification service
    NotificationManager mNotificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    // Sets an ID for the notification, so it can be updated

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setContentTitle(notificationData.getTitle()).setContentText(notificationData.getMessage())
            .setSmallIcon(R.drawable.default_icon);

    mBuilder.setDefaults(Notification.DEFAULT_ALL);

    // mBuilder.setNumber(++numMessages);
    Intent resultIntent = new Intent(context, SplashActivity.class);
    if (notificationData.getShowPopup().equals("1")) {
        resultIntent.putExtra("NOTIFICATION_DATA", notificationData);
    }/*from  w w w.j  a v a 2s  . c  o  m*/
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
    // Adds the back stack for the Intent (but not the Intent itself)
    stackBuilder.addParentStack(SplashActivity.class);
    // Adds the Intent that starts the Activity to the top of the stack

    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(notifyID,
            PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(resultPendingIntent);

    mBuilder.setAutoCancel(true);// cancel after click notification
    // mId allows you to update the notification later on.
    mNotificationManager.notify(++notifyID, mBuilder.build());

    // Update badge
    try {
        ShortcutBadger.setBadge(context, notifyID);
    } catch (ShortcutBadgeException e) {
    }
}

From source file:org.onebusaway.android.directions.realtime.RealtimeService.java

private void showNotification(ItineraryDescription description, int title, int message,
        Class<? extends Activity> notificationTarget, Bundle params, List<Itinerary> itineraries) {

    String titleText = getResources().getString(title);
    String messageText = getResources().getString(message);

    Intent openIntent = new Intent(getApplicationContext(), notificationTarget);
    openIntent.putExtras(params);/*from   w  w  w .j  a va2 s  .  com*/
    openIntent.putExtra(OTPConstants.INTENT_SOURCE, OTPConstants.Source.NOTIFICATION);
    openIntent.putExtra(OTPConstants.ITINERARIES, (ArrayList<Itinerary>) itineraries);
    openIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent openPendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, openIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext())
            .setSmallIcon(R.drawable.ic_stat_notification).setContentTitle(titleText)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(messageText)).setContentText(messageText)
            .setPriority(NotificationCompat.PRIORITY_MAX).setContentIntent(openPendingIntent);

    NotificationManager notificationManager = (NotificationManager) getApplicationContext()
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = mBuilder.build();
    notification.defaults = Notification.DEFAULT_ALL;
    notification.flags |= Notification.FLAG_AUTO_CANCEL | Notification.FLAG_SHOW_LIGHTS;

    Integer notificationId = description.getId();
    notificationManager.notify(notificationId, notification);
}

From source file:com.getpillion.gcm.GcmIntentService.java

private void sendNotification(Intent targetIntent, String msg) {
    mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);

    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, targetIntent, 0);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_launcher_white).setContentTitle(msg)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setPriority(2)
            .setContentText(greetingMessages[new Random().nextInt(greetingMessages.length)]);

    mBuilder.setContentIntent(contentIntent);
    Notification notification = mBuilder.build();
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.defaults |= Notification.DEFAULT_ALL;
    //notification.defaults |= Notification.DEFAULT_VIBRATE;
    mNotificationManager.notify(NOTIFICATION_ID, notification);
}

From source file:me.gpelaez.cordova.plugins.ibeacon.GPIBeacon.java

/**
 * + * Issues a notification to inform the user that server has sent a
 * message. +/*w w w. j  a va 2s  .c o  m*/
 * @throws JSONException 
 */
@SuppressLint("InlinedApi")
private static void createNotification(Context context, JSONObject json) throws JSONException {
    Bundle extra = new Bundle();
    extra.putString("json", json.toString());

    Intent notificationIntent = new Intent(activity, BeaconNotificationHandler.class);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    notificationIntent.putExtra("beacon", extra);

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

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setDefaults(Notification.DEFAULT_ALL).setSmallIcon(context.getApplicationInfo().icon)
            .setWhen(System.currentTimeMillis()).setTicker(json.getString("title"))
            .setContentTitle(json.getString("message")).setContentIntent(contentIntent);

    String message = json.getString("message");
    if (message != null) {
        mBuilder.setContentText(message);
    } else {
        mBuilder.setContentText("<missing message content>");
    }
    mBuilder.addAction(context.getApplicationInfo().icon, json.getString("message"), contentIntent);

    ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE))
            .notify((String) getAppName(context), NOTIFICATION_ID, mBuilder.build());
}

From source file:com.android.dialer.calllog.DefaultVoicemailNotifier.java

private int getNotificationDefaults(PhoneAccountHandle accountHandle) {
    if (ContactsUtils.FLAG_N_FEATURE) {
        return TelephonyManagerCompat.isVoicemailVibrationEnabled(getTelephonyManager(), accountHandle)
                ? Notification.DEFAULT_VIBRATE
                : 0;//  ww w . j  a v  a2s . c om
    }
    return Notification.DEFAULT_ALL;
}

From source file:org.dmfs.tasks.notification.NotificationUpdaterService.java

@SuppressLint("InlinedApi")
public void resendPinNotification(Uri taskUri) {
    if (taskUri == null) {
        return;/*from ww w.  j av a2s .co m*/
    }
    long taskId = ContentUris.parseId(taskUri);
    if (taskId < 0) {
        return;
    }
    Integer notificationId = Long.valueOf(taskId).intValue();
    mBuilder.setDefaults(Notification.DEFAULT_ALL);
    mBuilder.setOngoing(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        mBuilder.setPriority(Notification.PRIORITY_HIGH);
    }

    NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
    notificationManager.notify(notificationId, mBuilder.build());
}

From source file:com.skalski.websocketsclient.ActivityMain.java

@Override
public void onTextMessage(String payload) {

    try {//w w  w  .j  a va2s .c  o  m

        Log.i(TAG_LOG, "New message from server");
        JSONObject jsonObj = new JSONObject(payload);

        if ((jsonObj.has(TAG_JSON_TYPE)) && (jsonObj.has(TAG_JSON_MSG))) {

            /*
             * Notification
             */
            if (jsonObj.getString(TAG_JSON_TYPE).equals("notification")) {

                if (ActivitySettings.pref_notifications_disabled(getBaseContext())) {

                    Log.i(TAG_LOG, "Notifications are disabled");

                } else {

                    int notification_id;

                    if (ActivitySettings.pref_multiple_notifications_disabled(getBaseContext()))
                        notification_id = 0;
                    else
                        notification_id = (int) System.currentTimeMillis();

                    /* create new notification */
                    Notification new_notification = new Notification.Builder(this)
                            .setContentTitle(getResources().getString(R.string.app_name))
                            .setContentText(jsonObj.getString(TAG_JSON_MSG))
                            .setSmallIcon(R.drawable.ic_launcher).build();
                    new_notification.defaults |= Notification.DEFAULT_ALL;
                    NotificationManager notificationManager = (NotificationManager) getSystemService(
                            NOTIFICATION_SERVICE);
                    notificationManager.notify(notification_id, new_notification);

                    appendText(cmdOutput, "[SERVER] Asynchronous Notification\n",
                            Color.parseColor("#ff0099cc"));
                }

                /*
                 * Standard message
                 */
            } else if (jsonObj.getString(TAG_JSON_TYPE).equals("standard")) {

                appendText(cmdOutput, "[SERVER] " + jsonObj.getString(TAG_JSON_MSG) + "\n",
                        Color.parseColor("#ff99cc00"));

                /*
                 * JSON object is not valid
                 */
            } else {
                show_info(getResources().getString(R.string.info_msg_4), false);
                Log.e(TAG_LOG, "Received invalid JSON from server");
            }
        }
    } catch (JSONException e) {

        /* JSON object is not valid */
        show_info(getResources().getString(R.string.info_msg_4), false);
        Log.e(TAG_LOG, "Received invalid JSON from server");
    }
}

From source file:it.mb.whatshare.GCMIntentService.java

/**
 * Creates a notification informing the user that new content is to be
 * shared.//from   w w w .  java2 s. com
 * 
 * @param context
 *            the current application context
 * @param message
 *            the message to be shared
 * @param useWhatsapp
 *            whether the content should be shared bypassing the app choice
 *            dialog calling whatsapp directly instead
 */
@SuppressWarnings("deprecation")
public void generateNotification(Context context, String message, boolean useWhatsapp) {
    // @formatter:off
    String title = context.getString(R.string.whatshare);
    Class<?> dst = useWhatsapp ? SendToWhatsappActivity.class : SendToAppActivity.class;
    // setAction is called so filterEquals() always returns false for all
    // our intents
    Intent whatshareIntent = new Intent(context, dst).putExtra("message", message)
            .setAction(String.valueOf(System.currentTimeMillis())).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    PendingIntent intent = PendingIntent.getActivity(context, 0, whatshareIntent,
            Intent.FLAG_ACTIVITY_NEW_TASK);

    Notification notification = null;
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setSmallIcon(useWhatsapp ? R.drawable.notification_icon : R.drawable.whatshare_logo_notification,
                    0)
            .setContentTitle(title).setContentText(message).setContentIntent(intent)
            .setDefaults(Notification.DEFAULT_ALL);
    // @formatter:on

    if (Build.VERSION.SDK_INT > 15) {
        notification = buildForJellyBean(builder);
    } else {
        notification = builder.getNotification();
    }
    notification.flags |= Notification.FLAG_AUTO_CANCEL;

    ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE))
            .notify(counter.incrementAndGet(), notification);
}