Java Code Examples for android.support.v4.app.NotificationCompat#DEFAULT_SOUND
The following examples show how to use
android.support.v4.app.NotificationCompat#DEFAULT_SOUND .
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: NotificationsService.java From ForPDA with GNU General Public License v3.0 | 6 votes |
private void configureNotification(NotificationCompat.Builder builder) { builder.setAutoCancel(true); builder.setPriority(NotificationCompat.PRIORITY_DEFAULT); builder.setCategory(NotificationCompat.CATEGORY_SOCIAL); int defaults = 0; if (Preferences.Notifications.Main.isSoundEnabled(getApplicationContext())) { defaults |= NotificationCompat.DEFAULT_SOUND; } if (Preferences.Notifications.Main.isVibrationEnabled(getApplicationContext())) { defaults |= NotificationCompat.DEFAULT_VIBRATE; } if (Preferences.Notifications.Main.isIndicatorEnabled(getApplicationContext())) { defaults |= NotificationCompat.DEFAULT_LIGHTS; } builder.setDefaults(defaults); builder.setVibrate(new long[]{0L}); }
Example 2
Source File: AndroidNotifications.java From actor-platform with GNU Affero General Public License v3.0 | 5 votes |
public void addCustomLedAndSound(Notification topNotification, android.app.Notification result) { if (messenger().isNotificationSoundEnabled()) { result.defaults &= ~NotificationCompat.DEFAULT_SOUND; result.sound = ActorSDK.sharedActor().getDelegate().getNotificationSoundForPeer(topNotification.getPeer()); } result.ledARGB = ActorSDK.sharedActor().getDelegate().getNotificationColorForPeer(topNotification.getPeer()); if (result.ledARGB != 0) { result.ledOnMS = 100; result.ledOffMS = 100; result.defaults &= ~NotificationCompat.DEFAULT_LIGHTS; result.flags |= NotificationCompat.FLAG_SHOW_LIGHTS; } }
Example 3
Source File: PostNotification.java From Capstone-Project with MIT License | 4 votes |
private void showPostNotification(Post post, Bitmap bitmap) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { showHeaderNotification(); } PendingIntent pendingIntent = PendingIntent.getActivity(mContext, post.getPostId(), PostDetailsActivity.getLaunchIntent(mContext, post.getPostId()), PendingIntent.FLAG_ONE_SHOT); boolean sound = PredatorSharedPreferences.isNotificationSoundEnabled(mContext); boolean light = PredatorSharedPreferences.isNotificationLightEnabled(mContext); boolean vibrate = PredatorSharedPreferences.isNotificationVibrationEnabled(mContext); int defaultFlags = 0; if (sound) { defaultFlags |= NotificationCompat.DEFAULT_SOUND; } if (light) { defaultFlags |= NotificationCompat.DEFAULT_LIGHTS; } if (vibrate) { defaultFlags |= NotificationCompat.DEFAULT_VIBRATE; } NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext) .setColor(ContextCompat.getColor(mContext, R.color.notification_color_child)) .setSmallIcon(R.drawable.ic_notification_predator) .setLargeIcon(bitmap != null ? bitmap : getBitmap(R.mipmap.ic_launcher)) .setContentTitle(post.getName()) .setContentText(post.getTagline()) .setGroup(NOTIFICATION_GROUP_KEY) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setPriority(NotificationCompat.PRIORITY_HIGH) .setDefaults(defaultFlags) .setAutoCancel(true) .setOnlyAlertOnce(true) .setContentIntent(pendingIntent); mNotificationManager.notify(post.getPostId(), builder.build()); }