Java Code Examples for android.app.Notification#DEFAULT_ALL

The following examples show how to use android.app.Notification#DEFAULT_ALL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseNotificationHandler.java    From mobile-messaging-sdk-android with Apache License 2.0 6 votes vote down vote up
private void setNotificationSoundAndVibrate(NotificationCompat.Builder notificationBuilder, Message message) {
    int notificationDefaults = Notification.DEFAULT_ALL;
    if (!message.isVibrate()) {
        notificationDefaults &= ~Notification.DEFAULT_VIBRATE;
    } else if (ContextCompat.checkSelfPermission(context, Manifest.permission.VIBRATE) == PackageManager.PERMISSION_DENIED) {
        notificationDefaults &= ~Notification.DEFAULT_VIBRATE;
        MobileMessagingLogger.e("Unable to vibrate", new ConfigurationException(ConfigurationException.Reason.MISSING_REQUIRED_PERMISSION, Manifest.permission.VIBRATE));
    }
    if (!message.isDefaultSound()) {
        notificationDefaults &= ~Notification.DEFAULT_SOUND;
    }
    notificationBuilder.setDefaults(notificationDefaults);

    String sound = message.getSound();
    if (message.isDefaultSound() || StringUtils.isBlank(sound)) {
        return;
    }

    Uri soundUri = Uri.parse("android.resource://" + context.getPackageName() + "/raw/" + sound);
    if (soundUri == null) {
        MobileMessagingLogger.e("Cannot create uri for sound:" + sound + " messageId:" + message.getMessageId());
        return;
    }

    notificationBuilder.setSound(soundUri);
}
 
Example 2
Source File: NotificationManagerHelper.java    From q-municate-android with Apache License 2.0 6 votes vote down vote up
private static void sendChatNotificationEvent(Context context, Intent intent, NotificationEvent notificationEvent) {
    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        createChannelIfNotExist(notificationManager);
    }

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

    NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ONE_ID)
            .setSmallIcon(getNotificationIcon())
            .setContentTitle(notificationEvent.getTitle())
            .setColor(context.getResources().getColor(R.color.accent))
            .setStyle(new NotificationCompat.BigTextStyle().bigText(notificationEvent.getSubject()))
            .setContentText(notificationEvent.getBody())
            .setAutoCancel(true)
            .setContentIntent(contentIntent);

    Notification notification = builder.build();
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.defaults = Notification.DEFAULT_ALL;
    notificationManager.notify(NOTIFICATION_ID, notification);
}
 
Example 3
Source File: NotificationOptions.java    From financisto with GNU General Public License v2.0 5 votes vote down vote up
public void apply(Notification notification) {
	notification.defaults = 0;
	if (isOff()) {
		notification.defaults = 0;
	} else if (isDefault()) {
		notification.defaults = Notification.DEFAULT_ALL;
		enableLights(notification);
	} else {
		applySound(notification);
		applyVibration(notification);
		applyLed(notification);
	}
}
 
Example 4
Source File: FinancistoService.java    From financisto with GNU General Public License v2.0 5 votes vote down vote up
private void applyNotificationOptions(Notification notification, String notificationOptions) {
    if (notificationOptions == null) {
        notification.defaults = Notification.DEFAULT_ALL;
    } else {
        NotificationOptions options = NotificationOptions.parse(notificationOptions);
        options.apply(notification);
    }
}
 
Example 5
Source File: Notifications.java    From mpush-android with Apache License 2.0 5 votes vote down vote up
public void init(Context context) {
    this.context = context;
    this.nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    int defaults = Notification.DEFAULT_ALL
            | Notification.FLAG_AUTO_CANCEL;
    this.defaults = defaults;
}
 
Example 6
Source File: NotificationReceiver.java    From iSCAU-Android with GNU General Public License v3.0 5 votes vote down vote up
public void onReceive(Context context, Intent intent) {
   SharedPreferences shareDate =
            context.getSharedPreferences("timing",Activity.MODE_PRIVATE);
   int date = shareDate.getInt("date",1);
   String str = getNowDate(context, date);
   boolean flag = matchRecode(context, str);
   Log.v("test_dick",flag+"");

   if(flag){
     //context.startService(new Intent(context, cn.scau.scautreasure.service.NotificationService.class));

       try {
           NotificationManager mNotificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);

           int notificationIcon= R.drawable.icon;
           CharSequence notificationTitle="来自华农宝";
           long when = System.currentTimeMillis();

           Notification notification=new Notification(notificationIcon, notificationTitle, when);

           notification.defaults=Notification.DEFAULT_ALL;
           notification.flags |= Notification.FLAG_AUTO_CANCEL;

           Intent intentservice=new Intent(context.getApplicationContext(), BorrowedBook_.class);
           PendingIntent pendingIntent=PendingIntent.getActivity(context.getApplicationContext(), 0, intentservice, 0);
           notification.setLatestEventInfo(context.getApplicationContext(),"借阅到期提示", "你有N本书即将满借阅",pendingIntent);

           mNotificationManager.notify(1000, notification);

       } catch (Exception e) {
           e.printStackTrace();
       }

   }
}
 
Example 7
Source File: NotificationService.java    From iSCAU-Android with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public int onStartCommand(Intent intent,int flags,int startId)
{
    super.onStart(intent, startId);

    try {
                    NotificationManager mNotificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);

                    int notificationIcon= R.drawable.icon;
                    CharSequence notificationTitle="来自华农宝";
                    long when = System.currentTimeMillis();

                    Notification notification=new Notification(notificationIcon, notificationTitle, when);

                    notification.defaults=Notification.DEFAULT_ALL;
                    notification.flags |= Notification.FLAG_AUTO_CANCEL;

                    Intent intentservice=new Intent(getApplicationContext(), BorrowedBook_.class);
                    PendingIntent pendingIntent=PendingIntent.getActivity(getApplicationContext(), 0, intentservice, 0);
                    notification.setLatestEventInfo(getApplicationContext(),"借阅到期提示", "你有N本书即将满借阅",pendingIntent);

                    mNotificationManager.notify(1000, notification);

            } catch (Exception e) {
                e.printStackTrace();
            }

    return Service.START_CONTINUATION_MASK;
}
 
Example 8
Source File: AllSignal.java    From opentasks with Apache License 2.0 4 votes vote down vote up
@Override
public int value()
{
    return Notification.DEFAULT_ALL;
}