Java Code Examples for android.app.NotificationChannel#enableVibration()
The following examples show how to use
android.app.NotificationChannel#enableVibration() .
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: NotificationChannels.java From mollyim-android with GNU General Public License v3.0 | 7 votes |
@TargetApi(26) private static @NonNull NotificationChannel copyChannel(@NonNull NotificationChannel original, @NonNull String id) { NotificationChannel copy = new NotificationChannel(id, original.getName(), original.getImportance()); copy.setGroup(original.getGroup()); copy.setSound(original.getSound(), original.getAudioAttributes()); copy.setBypassDnd(original.canBypassDnd()); copy.enableVibration(original.shouldVibrate()); copy.setVibrationPattern(original.getVibrationPattern()); copy.setLockscreenVisibility(original.getLockscreenVisibility()); copy.setShowBadge(original.canShowBadge()); copy.setLightColor(original.getLightColor()); copy.enableLights(original.shouldShowLights()); return copy; }
Example 2
Source File: CompatHelperBase.java From edslite with GNU General Public License v2.0 | 6 votes |
public static synchronized String getFileOperationsNotificationsChannelId(Context context) { if (fileOperationsNotificationsChannelId == null) { fileOperationsNotificationsChannelId = "com.sovworks.eds.FILE_OPERATIONS_CHANNEL2"; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationChannel channel = new NotificationChannel( fileOperationsNotificationsChannelId, context.getString(R.string.file_operations_notifications_channel_name), NotificationManager.IMPORTANCE_LOW ); channel.enableLights(false); channel.enableVibration(false); NotificationManager notificationManager = context.getSystemService(NotificationManager.class); notificationManager.createNotificationChannel(channel); } } return fileOperationsNotificationsChannelId; }
Example 3
Source File: NotificationChannels.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 6 votes |
@RequiresApi(api = Build.VERSION_CODES.O) private synchronized void createNotificationChannel() { CharSequence name = MobiComKitConstants.PUSH_NOTIFICATION_NAME; int importance = NotificationManager.IMPORTANCE_HIGH; if (mNotificationManager != null && mNotificationManager.getNotificationChannel(MobiComKitConstants.AL_PUSH_NOTIFICATION) == null) { NotificationChannel mChannel = new NotificationChannel(MobiComKitConstants.AL_PUSH_NOTIFICATION, name, importance); mChannel.enableLights(true); mChannel.setLightColor(Color.GREEN); mChannel.setShowBadge(ApplozicClient.getInstance(context).isUnreadCountBadgeEnabled()); if (ApplozicClient.getInstance(context).getVibrationOnNotification()) { mChannel.enableVibration(true); mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400}); } AudioAttributes audioAttributes = new AudioAttributes.Builder() .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) .setUsage(AudioAttributes.USAGE_NOTIFICATION).build(); mChannel.setSound(TextUtils.isEmpty(soundFilePath) ? RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION) : Uri.parse(soundFilePath), audioAttributes); mNotificationManager.createNotificationChannel(mChannel); Utils.printLog(context, TAG, "Created notification channel"); } }
Example 4
Source File: MainActivity.java From BroadCastReceiver with Apache License 2.0 | 6 votes |
/** * for API 26+ create notification channels */ private void createchannel() { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationChannel mChannel = new NotificationChannel(id, getString(R.string.channel_name), //name of the channel NotificationManager.IMPORTANCE_DEFAULT); //importance level //important level: default is is high on the phone. high is urgent on the phone. low is medium, so none is low? // Configure the notification channel. mChannel.setDescription(getString(R.string.channel_description)); mChannel.enableLights(true); // Sets the notification light color for notifications posted to this channel, if the device supports this feature. mChannel.setLightColor(Color.RED); mChannel.enableVibration(true); mChannel.setShowBadge(true); mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400}); nm.createNotificationChannel(mChannel); } }
Example 5
Source File: SkyTubeApp.java From SkyTube with GNU General Public License v3.0 | 6 votes |
@TargetApi(26) private void initChannels(Context context) { if(BuildCompat.isAtLeastR()) { return; } NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); String channelId = NEW_VIDEOS_NOTIFICATION_CHANNEL; CharSequence channelName = context.getString(R.string.notification_channel_feed_title); int importance = NotificationManager.IMPORTANCE_LOW; NotificationChannel notificationChannel = new NotificationChannel(channelId, channelName, importance); notificationChannel.enableLights(true); notificationChannel.setLightColor(ColorUtils.compositeColors(0xFFFF0000, 0xFFFF0000)); notificationChannel.enableVibration(false); notificationManager.createNotificationChannel(notificationChannel); }
Example 6
Source File: NotificationHelper.java From adamant-android with GNU General Public License v3.0 | 6 votes |
@RequiresApi(Build.VERSION_CODES.O) public static String createSilentNotificationChannel(String channelId, String channelName, Context context){ NotificationChannel chan = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_NONE); chan.setDescription("Silent channel"); chan.setSound(null,null); chan.enableLights(false); chan.setLightColor(Color.BLUE); chan.enableVibration(false); chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); NotificationManager service = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); if (service != null) { service.createNotificationChannel(chan); } return channelId; }
Example 7
Source File: RCDevice.java From restcomm-android-sdk with GNU Affero General Public License v3.0 | 5 votes |
/** * Method returns the Notification builder * For Oreo devices we can have channels with HIGH and LOW importance. * If highImportance is true builder will be created with HIGH priority * For pre Oreo devices builder without channel will be returned * @param highImportance true if we need HIGH channel, false if we need LOW * @return */ private NotificationCompat.Builder getNotificationBuilder(boolean highImportance){ NotificationCompat.Builder builder; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { if (highImportance){ NotificationChannel channel = new NotificationChannel(PRIMARY_CHANNEL_ID, PRIMARY_CHANNEL, NotificationManager.IMPORTANCE_HIGH); channel.setLightColor(Color.GREEN); channel.enableLights(true); channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); channel.enableVibration(true); channel.setVibrationPattern(notificationVibrationPattern); ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(channel); builder = new NotificationCompat.Builder(RCDevice.this, PRIMARY_CHANNEL_ID); } else { NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationChannel notificationChannel = new NotificationChannel(DEFAULT_FOREGROUND_CHANNEL_ID, DEFAULT_FOREGROUND_CHANNEL, NotificationManager.IMPORTANCE_LOW); notificationManager.createNotificationChannel(notificationChannel); builder = new NotificationCompat.Builder(RCDevice.this, DEFAULT_FOREGROUND_CHANNEL_ID); } } else { builder = new NotificationCompat.Builder(RCDevice.this); } return builder; }
Example 8
Source File: KcaService.java From kcanotify_h5-master with GNU General Public License v3.0 | 5 votes |
private void createServiceChannel() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { int priority = IMPORTANCE_DEFAULT; if (getBooleanPreferences(getApplicationContext(), PREF_KCA_SET_PRIORITY)) { priority = IMPORTANCE_HIGH; } NotificationChannel channel = new NotificationChannel(getServiceChannelId(), SERVICE_CHANNEL_NAME, priority); channel.enableVibration(false); channel.setSound(null, null); channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); notifiManager.deleteNotificationChannel(SERVICE_CHANNEL_ID_OLD); notifiManager.createNotificationChannel(channel); } }
Example 9
Source File: Notifications.java From itag with GNU General Public License v3.0 | 5 votes |
private static void createDisconnectNotificationChannel() { if (!createdChannelDisconnected && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { CharSequence name = ITagApplication.context.getString(R.string.app_name); int importance = NotificationManager.IMPORTANCE_HIGH; NotificationChannel channel = new NotificationChannel(CHANNEL_DISCONNECT_ID, name, importance); channel.setSound(null, null); channel.setShowBadge(false); channel.enableVibration(true); NotificationManager notificationManager = ITagApplication.context.getSystemService(NotificationManager.class); if (notificationManager != null) { notificationManager.createNotificationChannel(channel); createdChannelDisconnected = true; } } }
Example 10
Source File: RootExecService.java From InviZible with GNU General Public License v3.0 | 5 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && notificationManager != null) { NotificationChannel notificationChannel = new NotificationChannel (ROOT_CHANNEL_ID, getString(R.string.notification_channel_root), NotificationManager.IMPORTANCE_LOW); notificationChannel.setDescription(""); notificationChannel.setSound(null, Notification.AUDIO_ATTRIBUTES_DEFAULT); notificationChannel.enableLights(false); notificationChannel.enableVibration(false); notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); notificationManager.createNotificationChannel(notificationChannel); sendNotification(getString(R.string.app_name), getText(R.string.notification_temp_text).toString()); } if (intent == null) { stopService(startId); return START_NOT_STICKY; } final String action = intent.getAction(); if ((action == null) || (action.isEmpty())) { stopService(startId); return START_NOT_STICKY; } if (action.equals(RUN_COMMAND)) { RootCommands rootCommands = (RootCommands) intent.getSerializableExtra("Commands"); int mark = intent.getIntExtra("Mark", 0); ExecRunnable execCommands = new ExecRunnable(rootCommands, mark, startId); executorService.execute(execCommands); } return START_NOT_STICKY; }
Example 11
Source File: EarthquakeUpdateJobService.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 5 votes |
private void createNotificationChannel() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { CharSequence name = getString(R.string.earthquake_channel_name); NotificationChannel channel = new NotificationChannel( NOTIFICATION_CHANNEL, name, NotificationManager.IMPORTANCE_HIGH); channel.enableVibration(true); channel.enableLights(true); NotificationManager notificationManager = getSystemService(NotificationManager.class); notificationManager.createNotificationChannel(channel); } }
Example 12
Source File: EarthquakeUpdateJobService.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 5 votes |
private void createNotificationChannel() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { CharSequence name = getString(R.string.earthquake_channel_name); NotificationChannel channel = new NotificationChannel( NOTIFICATION_CHANNEL, name, NotificationManager.IMPORTANCE_HIGH); channel.enableVibration(true); channel.enableLights(true); NotificationManager notificationManager = getSystemService(NotificationManager.class); notificationManager.createNotificationChannel(channel); } }
Example 13
Source File: NotifyManager.java From Tok-Android with GNU General Public License v3.0 | 5 votes |
private void createNotifyChannel() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (mNotificationManager != null) { mNotificationManager.createNotificationChannelGroup( new NotificationChannelGroup(mGroupId, mGroupName)); NotificationChannel channelMsg = new NotificationChannel(mChannelMsgId, mChannelMsgName, NotificationManager.IMPORTANCE_DEFAULT); channelMsg.setDescription(mChannelMsgDes); channelMsg.enableLights(true); channelMsg.setLightColor(Color.BLUE); channelMsg.enableVibration(false); channelMsg.setVibrationPattern(new long[] { 100, 200, 300, 400 }); channelMsg.setShowBadge(true); channelMsg.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); channelMsg.setGroup(mGroupId); mNotificationManager.createNotificationChannel(channelMsg); NotificationChannel channelService = new NotificationChannel(mChannelServiceId, mChannelServiceName, NotificationManager.IMPORTANCE_LOW); channelService.setDescription(mChannelServiceDes); channelService.enableLights(false); channelService.enableVibration(false); channelService.setShowBadge(false); channelService.setSound(null, null); channelService.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); channelService.setGroup(mGroupId); mNotificationManager.createNotificationChannel(channelService); } } }
Example 14
Source File: NotificationStatusBarWithCustomViewActivity.java From coursera-android with MIT License | 5 votes |
private void createNotificationChannel() { mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mChannelID = getPackageName() + ".channel_01"; // The user-visible name of the channel. CharSequence name = getString(R.string.channel_name); // The user-visible description of the channel. String description = getString(R.string.channel_description); int importance = NotificationManager.IMPORTANCE_HIGH; NotificationChannel mChannel = new NotificationChannel(mChannelID, name, importance); // Configure the notification channel. mChannel.setDescription(description); mChannel.enableLights(true); // Sets the notification light color for notifications posted to this // channel, if the device supports this feature. mChannel.setLightColor(Color.RED); mChannel.enableVibration(true); mChannel.setVibrationPattern(mVibratePattern); //Uri soundURI = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.alarm_rooster); mChannel.setSound(soundURI, (new AudioAttributes.Builder()).setUsage(AudioAttributes.USAGE_NOTIFICATION).build()); mNotificationManager.createNotificationChannel(mChannel); }
Example 15
Source File: NotificationController.java From MiPushFramework with GNU General Public License v3.0 | 5 votes |
@TargetApi(26) private static NotificationChannel createChannelWithPackage(@NonNull String packageName, @NonNull CharSequence name) { NotificationChannel channel = new NotificationChannel(getChannelIdByPkg(packageName), name, NotificationManager.IMPORTANCE_DEFAULT); channel.enableVibration(true); return channel; }
Example 16
Source File: MainActivity.java From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 | 5 votes |
public void createNotificationChannel(){ mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ NotificationChannel mNotificationChannel = new NotificationChannel(PRIMARY_CHANNEL_ID, getString(R.string.channel_name), NotificationManager.IMPORTANCE_HIGH); mNotificationChannel.enableLights(true); mNotificationChannel.setLightColor(Color.RED); mNotificationChannel.enableVibration(true); mNotificationChannel.setDescription(getString(R.string.channel_desc)); mNotificationManager.createNotificationChannel(mNotificationChannel); } }
Example 17
Source File: EarthquakeUpdateJobService.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 5 votes |
private void createNotificationChannel() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { CharSequence name = getString(R.string.earthquake_channel_name); NotificationChannel channel = new NotificationChannel( NOTIFICATION_CHANNEL, name, NotificationManager.IMPORTANCE_HIGH); channel.enableVibration(true); channel.enableLights(true); NotificationManager notificationManager = getSystemService(NotificationManager.class); notificationManager.createNotificationChannel(channel); } }
Example 18
Source File: NotificationChannels.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@TargetApi(26) private static void onCreate(@NonNull Context context, @NonNull NotificationManager notificationManager) { NotificationChannelGroup messagesGroup = new NotificationChannelGroup(CATEGORY_MESSAGES, context.getResources().getString(R.string.NotificationChannel_group_messages)); notificationManager.createNotificationChannelGroup(messagesGroup); NotificationChannel messages = new NotificationChannel(getMessagesChannel(context), context.getString(R.string.NotificationChannel_messages), NotificationManager.IMPORTANCE_HIGH); NotificationChannel calls = new NotificationChannel(CALLS, context.getString(R.string.NotificationChannel_calls), NotificationManager.IMPORTANCE_HIGH); NotificationChannel failures = new NotificationChannel(FAILURES, context.getString(R.string.NotificationChannel_failures), NotificationManager.IMPORTANCE_HIGH); NotificationChannel backups = new NotificationChannel(BACKUPS, context.getString(R.string.NotificationChannel_backups), NotificationManager.IMPORTANCE_LOW); NotificationChannel lockedStatus = new NotificationChannel(LOCKED_STATUS, context.getString(R.string.NotificationChannel_locked_status), NotificationManager.IMPORTANCE_LOW); NotificationChannel other = new NotificationChannel(OTHER, context.getString(R.string.NotificationChannel_other), NotificationManager.IMPORTANCE_LOW); messages.setGroup(CATEGORY_MESSAGES); messages.enableVibration(TextSecurePreferences.isNotificationVibrateEnabled(context)); messages.setSound(TextSecurePreferences.getNotificationRingtone(context), getRingtoneAudioAttributes()); setLedPreference(messages, TextSecurePreferences.getNotificationLedColor(context)); calls.setShowBadge(false); backups.setShowBadge(false); lockedStatus.setShowBadge(false); other.setShowBadge(false); notificationManager.createNotificationChannels(Arrays.asList(messages, calls, failures, backups, lockedStatus, other)); if (BuildConfig.AUTOMATIC_UPDATES) { NotificationChannel appUpdates = new NotificationChannel(APP_UPDATES, context.getString(R.string.NotificationChannel_app_updates), NotificationManager.IMPORTANCE_HIGH); notificationManager.createNotificationChannel(appUpdates); } else { notificationManager.deleteNotificationChannel(APP_UPDATES); } }
Example 19
Source File: ApiTwentySixPlus.java From linphone-android with GNU General Public License v3.0 | 5 votes |
public static void createServiceChannel(Context context) { NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // Create service/call notification channel String id = context.getString(R.string.notification_service_channel_id); CharSequence name = context.getString(R.string.content_title_notification_service); String description = context.getString(R.string.content_title_notification_service); NotificationChannel channel = new NotificationChannel(id, name, NotificationManager.IMPORTANCE_LOW); channel.setDescription(description); channel.enableVibration(false); channel.enableLights(false); channel.setShowBadge(false); notificationManager.createNotificationChannel(channel); }
Example 20
Source File: Config.java From Hify with MIT License | 4 votes |
@RequiresApi(api = Build.VERSION_CODES.O) public static void createNotificationChannels(Context context){ NotificationManager notificationManager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); List<NotificationChannelGroup> notificationChannelGroups=new ArrayList<>(); notificationChannelGroups.add(new NotificationChannelGroup("hify","Hify")); notificationChannelGroups.add(new NotificationChannelGroup("other","Other")); notificationManager.createNotificationChannelGroups(notificationChannelGroups); NotificationChannel flash_message_channel=new NotificationChannel("flash_message","Flash Messages",NotificationManager.IMPORTANCE_HIGH); flash_message_channel.enableLights(true); flash_message_channel.enableVibration(true); flash_message_channel.setGroup("hify"); flash_message_channel.setSound(Uri.parse("android.resource://"+context.getPackageName()+"/"+ R.raw.hify_sound), null); NotificationChannel comments_channel=new NotificationChannel("comments_channel","Comments",NotificationManager.IMPORTANCE_HIGH); comments_channel.enableLights(true); comments_channel.enableVibration(true); comments_channel.setGroup("hify"); comments_channel.setSound(Uri.parse("android.resource://"+context.getPackageName()+"/"+ R.raw.hify_sound), null); NotificationChannel like_channel=new NotificationChannel("like_channel","Likes",NotificationManager.IMPORTANCE_HIGH); like_channel.enableLights(true); like_channel.enableVibration(true); like_channel.setGroup("hify"); like_channel.setSound(Uri.parse("android.resource://"+context.getPackageName()+"/"+ R.raw.hify_sound), null); NotificationChannel forum_channel=new NotificationChannel("forum_channel","Forum",NotificationManager.IMPORTANCE_HIGH); forum_channel.enableLights(true); forum_channel.enableVibration(true); forum_channel.setGroup("hify"); forum_channel.setSound(Uri.parse("android.resource://"+context.getPackageName()+"/"+ R.raw.hify_sound), null); NotificationChannel sending_channel=new NotificationChannel("sending_channel","Sending Media",NotificationManager.IMPORTANCE_LOW); sending_channel.enableLights(true); sending_channel.enableVibration(true); sending_channel.setGroup("other"); NotificationChannel other_channel=new NotificationChannel("other_channel","Other Notifications",NotificationManager.IMPORTANCE_LOW); other_channel.enableLights(true); other_channel.enableVibration(true); other_channel.setGroup("other"); NotificationChannel hify_other_channel=new NotificationChannel("hify_other_channel","Other Notifications",NotificationManager.IMPORTANCE_LOW); hify_other_channel.enableLights(true); hify_other_channel.enableVibration(true); hify_other_channel.setGroup("hify"); hify_other_channel.setSound(Uri.parse("android.resource://"+context.getPackageName()+"/"+ R.raw.hify_sound), null); List<NotificationChannel> notificationChannels=new ArrayList<>(); notificationChannels.add(flash_message_channel); notificationChannels.add(like_channel); notificationChannels.add(comments_channel); notificationChannels.add(forum_channel); notificationChannels.add(sending_channel); notificationChannels.add(other_channel); notificationChannels.add(hify_other_channel); notificationManager.createNotificationChannels(notificationChannels); }