android-notifications

Android notification with buttons on it

随声附和 提交于 2019-12-17 08:54:29
问题 I'm trying to make a notification with 2 buttons on it: one takes me back to the activity the other closes it Has anyone got an idea on how to catch the button click event (remember that the Activity is paused)? 回答1: I am glad to post it! After working all night I found something. So, here we go! 1. Create an xml layout file for your notification. 2. Create the notification using the Notification.Builder. After adding everything you want (icons, sounds, etc) do this: //R.layout.notification

Clicking on Notification is not starting intended activity?

依然范特西╮ 提交于 2019-12-17 07:30:20
问题 I am using GCM in my application and also using NotificationManager to Create a Notification whenever GCM message is received.Till now everything is working perfectly and GCM message is showing correctly in Notification area, but when I click on the notification it should start an activity of my application which will display the message detail which is not happening. Every-time I click on notification it does not start any activity and it remains as is.My code for creating Notification is :

Android: Is it possible to update a ImageView/ImageButton with a number to show the number of new messages?

拟墨画扇 提交于 2019-12-17 07:18:11
问题 In iOS we have a feature to update the app icon with the new pending messages for the user by showing a small number on the right-top corner of the icon and similarly I would like to know if we have method to update a ImageView/ImageButton in android(Here I am not looking to update the icon on the home screen but inside my app). For example, the pic shows the red background icon with the number of messages pending to be read in red and if there are no messages it shows with a gray background.

How to display multiple notifications in android

梦想的初衷 提交于 2019-12-17 07:07:29
问题 I am receiving only one notification and if there is another notification comes, it replaces the previous one and here is my code private static void generateNotification(Context context, String message, String key) { int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); String title =

Android multiple line notification like Gmail app

狂风中的少年 提交于 2019-12-17 06:34:39
问题 I am trying to create a multiple line notification like the Gmail application does as shown in the image below (the 5 notifications grouped under one notification) I have tried various examples but can only seem to create single notifications like public void createSingleNotification(String title, String messageText, String tickerttext) { int icon = R.drawable.notification_icon; // icon from resources CharSequence tickerText = tickerttext; // ticker-text long when = System.currentTimeMillis()

Cancel notification on remove application from multitask panel

妖精的绣舞 提交于 2019-12-17 04:54:35
问题 I manage an ONGOING notification from my application (not from a service). When I kill application from task manager with "End" button, notification disappear . When I remove application from multitask pannel, application is killed but notification remains . My questions are: How to catch this event to clear notification? What happens when application is removed from multitask pannel? Application is destroyed but process staying alive? Is it normal? As an update: All my activities extends

On Android 8.1 API 27 notification does not display

隐身守侯 提交于 2019-12-17 04:28:19
问题 I get Toast on Android 8.1 API 27: Developer warning for package "my_package_name" Failed to post notification on ... Logcat includes next strings: Notification: Use of stream types is deprecated for operations other than volume control W/Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case E/NotificationService: No Channel found for pkg=my_package_name The full information in the Toast and in Logcat can

How to create a notification with NotificationCompat.Builder?

◇◆丶佛笑我妖孽 提交于 2019-12-17 02:34:28
问题 I need to create a simple notification which will be shown in notification bar along with the sound and icon if possible? I also need it to be compatitible with Android 2.2, so i found that NotificationCompat.Builder works with all APIs above 4. If there's a better solution, feel free to mention it. 回答1: The NotificationCompat.Builder is the most easy way to create Notifications on all Android versions. You can even use features that are available with Android 4.1. If your app runs on devices

Notification not showing in Oreo

天涯浪子 提交于 2019-12-16 19:32:21
问题 Normal Notification Builder doesn't show notifications on Android O. How could I show notification on Android 8 Oreo? Is there any new piece of code to add for showing notification on Android O? 回答1: In Android O it's a must to use a channel with your Notification Builder below is a sample code : // Sets an ID for the notification, so it can be updated. int notifyID = 1; String CHANNEL_ID = "my_channel_01";// The id of the channel. CharSequence name = getString(R.string.channel_name);// The

Notification on android device disappears

大城市里の小女人 提交于 2019-12-14 02:55:35
问题 So I've noticed on my android device (Marshmallow) that a new email (Gmail) notification goes away if I view the new email in my desktop. Same goes for WhatsApp messages. I was just wondering how this is implemented. Obviously tried Googling this, but all I found was on Clearing the notifications or disabling them. 回答1: The application is calling a servlet to see if there are any new/unread messages via a background service. When you view the message on your PC, the service is updated with