android-notifications

Perform Action On Button Click in Custom Notification : Android

家住魔仙堡 提交于 2019-12-18 02:58:51
问题 I am trying to perform some action like pause music , play music on button click of a custom notification in android. Currently I am doing it in this way , int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, "Custom Notification", when); NotificationManager mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.layout);

Custom Notification Sound not working in Oreo

六眼飞鱼酱① 提交于 2019-12-17 23:42:43
问题 Uri sound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + context.getPackageName() + "/" + R.raw.notification_mp3); mBuilder.setSound(sound); I had copied the mp3 (notification_mp3.mp3) file into the raw folder in the res folder. When the notification is triggered it produces given mp3 sound upto Android Nougat but default sound in Android Oreo . I had referred many sites but nothing worked on Android Oreo . I didn't find any changes in Android Docs regarding notification sound

Notification not getting removed on clicking action button even after providing the notification id

冷暖自知 提交于 2019-12-17 20:51:21
问题 I'm delivering a notification which has 2 action buttons namely "Accept" and "Reject". I'm following this Github repo. When user clicks "Accept", certain conditions are checked and the logic is performed accordingly. UPDATE 2.0 - The problem is that upon clicking "Accept" button, operation is happening successfully but the notification isn't disappearing from the status bar because the id generating here: m = (new Random()).nextInt(10000); is different from here: actionIntent.putExtra("id",

Can NoticationManager.notify() be called from a worker thread?

强颜欢笑 提交于 2019-12-17 18:03:54
问题 My question is more about what is a good practice than what is possible: Is it a good thing to call NoticationManager.notify() from a worker thread? Does the system execute it in the UI thread anyway or not? I always try to keep in mind that stuff concerning the UI should be executed in the UI thread and the rest in worker threads, as suggested by the Android doc about Processes And Threads: Additionally, the Andoid UI toolkit is not thread-safe. So, you must not manipulate your UI from a

Listen to incoming Whatsapp messages/notifications

ぃ、小莉子 提交于 2019-12-17 17:33:33
问题 I'm working on a notification based app, for which I need to listen to incoming notifications. I've been able to listen to incoming calls, SMS, mail etc. I have no clue how to listen for pings or messages from friends on Whatsapp via code. Can this actually be done? If so, how? Can Accessibility Service be used for this, using Package Name as "com.whatsapp"? 回答1: I was able to do this using Accessibility Service . Using this, you can listen to all notification on the notification bar. I

How to get android notifications when app was closed?

南楼画角 提交于 2019-12-17 15:35:54
问题 From webserivce I am getting data in the form of dates and time, means for some particular date i am having some set of slots. The following diagram gives the detailed explanation. Here on each date I have some set to timings. Here what i want is to display notification at the particular date and time. If the response from database consists of tomorrow date like 07/12/2012 at 11:00 AM. I need to display notification at that time. I have some idea regarding notification manager and code i am

Honeycomb notifications - How to set largeIcon to the right size?

两盒软妹~` 提交于 2019-12-17 15:34:40
问题 I find myself curious why the setLargeIcon method on Notification.Builder only accepts a Bitmap, with no overload to provide a resource id. Perhaps it was done for performance reasons, but it seems odd as setSmallIcon does accept a res drawable id. Notification.Builder builder = new Notification.Builder(application); // .... builder.setLargeIcon(iconBitmap); // Requires a Bitmap builder.setSmallIcon(iconResId); // Requires a drawable resource ID Notification notification = builder

How to remove notification from notification bar programmatically in android?

*爱你&永不变心* 提交于 2019-12-17 15:34:36
问题 Anybody have idea how can we remove notification from application programmatically which is called using Pending intent. I have used to cancel notification using following method. AlarmManager am=(AlarmManager)getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(Display.this, TwoAlarmService.class); PendingIntent pi = PendingIntent.getBroadcast(Display.this, AlarmNumber, intent, PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(pi); But problem is notification which fired already

Bad notification posted - Couldn't expand RemoteViews for: StatusBarNotification

陌路散爱 提交于 2019-12-17 10:56:35
问题 I am trying to post a notification with a custom view in the notification area from an IntentService , and getting the Couldn't expand RemoteView error. Here's what I am doing in onCreate() : mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); icon = R.drawable.icon; tickerText = "data upload in progress"; contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.notiflayout); contentView.setImageViewResource(R.id.image, R

Android Color Notification Icon

半世苍凉 提交于 2019-12-17 10:44:27
问题 I'm working on an app where I create a notification for the user. I want the icon to appear as white when it's in the status bar, but colored blue when it's being displayed in the drop down notification menu. Here's an example of the same thing being done by the Google Store app. White notification in status bar: Colored notification in drop down menu: How can I replicate this? What properties do I have to set? Edit: Here's my current code - I made the image all white with a transparent