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.tcnr14.example.GCMIntentService.java

private static void generateNotification(Context context, Bundle data) {
    int icon = R.drawable.ic_launcher;
    long when = System.currentTimeMillis();
    NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    Intent ni = new Intent(context, MainActivity.class);
    ni.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent intent = PendingIntent.getActivity(context, 0, ni, 0);
    Notification noti = new NotificationCompat.Builder(context).setContentTitle("GCM")//Title      
            .setContentText(data.getString("Notice"))//   
            .setContentIntent(intent)//??
            .setDefaults(Notification.DEFAULT_ALL)//????(+)
            .setSmallIcon(icon)//?icon
            .setWhen(when).build();//
    nm.notify(0, noti);//from   w w w  .  ja va  2 s. co m
}

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

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

        manage.setData(pkgUri);//ww  w  . j  av  a2s.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);

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

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
                && mgr.getNotificationChannel(CHANNEL_WHATEVER) == null) {
            mgr.createNotificationChannel(new NotificationChannel(CHANNEL_WHATEVER, "Whatever",
                    NotificationManager.IMPORTANCE_DEFAULT));
        }

        NotificationCompat.Builder b = new NotificationCompat.Builder(ctxt, CHANNEL_WHATEVER);
        String text = String.format(ctxt.getString(R.string.msg_requested), operation, 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));

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

From source file:com.dgsd.android.ShiftTracker.Service.NotificationService.java

private void showAlarmNotification(Shift shift) {
    if (shift == null)
        return;//www. ja  v a2 s.c o m

    try {
        NotificationCompat.Builder b = new NotificationCompat.Builder(this);
        b.setAutoCancel(true);
        b.setPriority(NotificationCompat.PRIORITY_HIGH);
        b.setDefaults(Notification.DEFAULT_ALL);
        b.setTicker("Reminder: " + shift.name);
        b.setSmallIcon(R.drawable.stat_notify_calendar);
        b.setContentTitle(shift.name);
        b.setContentText(getContentText(shift));
        b.setWhen(shift.getStartTime());

        final Intent contentIntent = new Intent(this, EditShiftActivity.class);
        contentIntent.putExtra(EditShiftActivity.EXTRA_SHIFT, shift);
        contentIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        b.setContentIntent(PendingIntent.getActivity(this, shift.hashCode(), contentIntent,
                PendingIntent.FLAG_UPDATE_CURRENT));

        notify(Tag.REMINDER, (int) shift.id, b.build());
    } catch (Exception e) {
        if (BuildConfig.DEBUG) {
            Log.e(TAG, "Error creating event reminder notification", e);
        }
    }

}

From source file:org.jboss.aerogear.cordova.geo.ProximityReceiver.java

public void createNotification(Context context, String id, String status) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    String appName = getAppName(context);

    Intent notificationIntent = new Intent(context, ProxyActivity.class);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    notificationIntent.putExtra("id", id);
    notificationIntent.putExtra("status", status);

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

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setDefaults(Notification.DEFAULT_ALL).setSmallIcon(context.getApplicationInfo().icon)
            .setWhen(System.currentTimeMillis()).setContentTitle(appName).setTicker(appName).setAutoCancel(true)
            .setContentIntent(contentIntent);

    if (GeofencingPlugin.getNotifyMessage() != null) {
        builder.setContentText(String.format(GeofencingPlugin.getNotifyMessage(), id, status));
    } else {//from w  w  w . j  av a2  s.c  om
        builder.setContentText("You have " + status + " your point of interest");
    }

    notificationManager.notify(appName, NOTIFICATION_ID, builder.build());
}

From source file:org.jboss.aerogear.cordova.push.NotificationMessageHandler.java

public void createNotification(Context context, Bundle extras) {
    NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    String appName = getAppName(context);

    Intent notificationIntent = new Intent(context, PushHandlerActivity.class);
    notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    notificationIntent.putExtra("pushBundle", extras);

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

    final String title = extras.getString("title");
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            .setDefaults(Notification.DEFAULT_ALL).setSmallIcon(context.getApplicationInfo().icon)
            .setWhen(System.currentTimeMillis()).setContentTitle(title != null ? title : appName)
            .setTicker(appName).setAutoCancel(true).setContentIntent(contentIntent);

    String message = extras.getString("alert");
    if (message != null) {
        builder.setContentText(message);
    } else {//www.ja  va 2s  . c o  m
        builder.setContentText("<missing message content>");
    }

    String msgcnt = extras.getString("msgcnt");
    if (msgcnt != null) {
        builder.setNumber(Integer.parseInt(msgcnt));
    }

    manager.notify(appName, NOTIFICATION_ID, builder.build());
}

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

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

    b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL).setContentTitle(getString(R.string.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_ID2, b.build());/*w  w w . j av a 2 s  .co  m*/
}

From source file:org.gluu.super_gluu.util.FakeDataUtil.java

public static void sendNotification(Context context) {

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

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    String contentText = "Example Content Text";

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context,
            GluuApplication.CHANNEL_ID).setContentIntent(getFakePendingIntent(context))
                    .setSmallIcon(R.drawable.push_icon).setSound(defaultSoundUri)
                    .setContentTitle("Example Title").setContentText(contentText)
                    .setStyle(new NotificationCompat.BigTextStyle().bigText(contentText))
                    .setChannelId(GluuApplication.CHANNEL_ID).setDefaults(Notification.DEFAULT_ALL)
                    .setAutoCancel(true).setVibrate(new long[] { 100, 250, 100, 250, 100, 250 })
                    .setPriority(Notification.PRIORITY_MAX)
                    .addAction(R.drawable.deny_icon_push, "Deny", getFakePendingIntent(context))
                    .addAction(R.drawable.approve_icon_push, "Approve", getFakePendingIntent(context));

    if (notificationManager != null) {
        notificationManager.notify(MainNavDrawerActivity.MESSAGE_NOTIFICATION_ID, notificationBuilder.build());
    }//from w ww.  j  av a 2  s  . c  om
}

From source file:com.commonsware.android.lollipopnotify.AlarmReceiver.java

private NotificationCompat.Builder buildBase(Context ctxt, int titleId) {
    NotificationCompat.Builder b = new NotificationCompat.Builder(ctxt);

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

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

From source file:com.example.fiveguys.trip_buddy_v0.fcm.MyFirebaseMessagingService.java

/**
 * Create and show a simple notification containing the received FCM message.
 *//*  www  . j  a va  2  s  .c o  m*/
public static void sendNotification(Context context, String messageBody, String channelUrl) {
    Intent intent = new Intent(context, com.example.fiveguys.trip_buddy_v0.main.ChatActivity.class);
    intent.putExtra("groupChannelUrl", channelUrl);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

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

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setContentTitle(context.getResources().getString(R.string.app_name)).setContentText(messageBody)
            .setAutoCancel(true).setSound(defaultSoundUri).setPriority(Notification.PRIORITY_MAX)
            .setDefaults(Notification.DEFAULT_ALL).setContentIntent(pendingIntent);

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

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

From source file:com.xxjwd.push.Notify.java

public static void notifcation(Context context, String messageString, Intent intent, String contentTitle) {

   //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();



   //the message that will be displayed as the ticker
   String ticker = contentTitle + " " + messageString;
       /*from   ww w.j a  v a2s  .c  o  m*/
   //build the pending intent that will start the appropriate activity
   PendingIntent pendingIntent = PendingIntent.getActivity(context,
       1, intent, 0);

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

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

 }