How do I check whether a specific notification channel is enabled in Android Oreo?

with backwards compatibility: public boolean isNotificationChannelEnabled(Context context, @Nullable String channelId){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if(!TextUtils.isEmpty(channelId)) { NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationChannel channel = manager.getNotificationChannel(channelId); return channel.getImportance() != NotificationManager.IMPORTANCE_NONE; } return false; } else { return NotificationManagerCompat.from(context).areNotificationsEnabled(); } }

Android notification setSound is not working

below code will help you: String CHANNEL_ID=”1234″; Uri soundUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + “://”+ getApplicationContext().getPackageName() + “/” + R.raw.mysound); NotificationManager mNotificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); //For API 26+ you need to put some additional code like below: NotificationChannel mChannel; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { mChannel = new NotificationChannel(CHANNEL_ID, Utils.CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH); mChannel.setLightColor(Color.GRAY); mChannel.enableLights(true); mChannel.setDescription(Utils.CHANNEL_SIREN_DESCRIPTION); AudioAttributes audioAttributes = new … Read more

On Android 8.1 API 27 notification does not display

If you get this error should be paid attention to 2 items and them order: NotificationChannel mChannel = new NotificationChannel(id, name, importance); builder = new NotificationCompat.Builder(context, id); Also NotificationManager notifManager and NotificationChannel mChannel are created only once. There are required setters for Notification: builder.setContentTitle() // required .setSmallIcon() // required .setContentText() // required See example: private … Read more

How to set the app icon as the notification icon in the notification drawer

I know its bit late to answer here and also its already been answered, but I came here looking for an easy fix using firebase notifications. Someone like me visiting here can do the solution by recommended and easy way of firebase notification, which is simply adding meta-data in manifest. Reference <!– Set custom default … Read more

How to Schedule Notification in Android

NOT FOR USE IN OREO+ (edit) The answers above are good – but don’t consider the user’s potential to restart the device (which clears PendingIntent’s scheduled by AlarmManager). You need to create a WakefulBroadcastReceiver, which will contain an AlarmManager to schedule deliver a PendingIntent. When the WakefulBroadcastReceiver handles the intent – post your notification and … Read more

How to update Notification with RemoteViews?

Here’s a detail example for you to update the notification using RemoteViews: private static final int NOTIF_ID = 1234; private NotificationCompat.Builder mBuilder; private NotificationManager mNotificationManager; private RemoteViews mRemoteViews; private Notification mNotification; … // call this method to setup notification for the first time private void setUpNotification(){ mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); // we need to build … Read more

Is possible set Expanded Notification as default in Big Text Notifications?

The documentation states: A notification’s big view appears only when the notification is expanded, which happens when the notification is at the top of the notification drawer, or when the user expands the notification with a gesture. So my answer is no, you can’t expand it by default. There is however a trick to push … Read more

tech