android-notifications

How to count number of notification and display single icon in Android?

妖精的绣舞 提交于 2019-11-30 09:11:44
I have multiple Android notification, but when I send a message from my web server, the android device creates a new notification icon on status bar. I want to count the number of unread notification, display it on statusbar with single icon, and when a notification is read, the notification has to change the number of unread notification count. How can I do it? It's look like "3 Others" in this image: Notification Icon Mortimer Check out the answer here: How to give counter if more than one Notifications are there You just have to set Notification.number : Notification notification = new

Create an Android notification with expiration date

拜拜、爱过 提交于 2019-11-30 08:48:18
问题 I would like to create a notification in Android that has an expiration date, meaning that on a certain date, if it's not open, it will be automatically destroyed or removed. Is this possible? Does someone knows how to do this? Thanks for your help. 回答1: You can remove your own app's notifications if you have the notification ID by calling NotificationManager.cancel. To implement the expiration, you can set an alarm with AlarmManager to wake up a BroadcastReceiver that will simply cancel the

putExtra using pending intent not working

会有一股神秘感。 提交于 2019-11-30 08:06:31
I have written a code in my GCMIntentservice that sends push notifications to many users. I use the NotificationManager that will call DescriptionActivity class when the notification is clicked. I also send the event_id form the GCMIntentService to the DescriptionActivity protected void onMessage(Context ctx, Intent intent) { message = intent.getStringExtra("message"); String tempmsg=message; if(message.contains("You")) { String temparray[]=tempmsg.split("="); event_id=temparray[1]; } nm= (NotificationManager)getSystemService(NOTIFICATION_SERVICE); intent = new Intent(this, DescriptionActivity

NotificationChannel issue in Android O

China☆狼群 提交于 2019-11-30 07:52:13
I am getting a toast saying "Developer warning for package com.google.android.apps.messaging" when sending an MMS using Android Messages ver 2.3.063. In logs 08-12 16:57:52.368 7661 7682 W Notification: Use of stream types is deprecated for operations other than volume control 08-12 16:57:52.368 7661 7682 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case 08-12 16:57:52.369 1604 3146 E NotificationService: No Channel found for pkg=com.google.android.apps.messaging, channelId=miscellaneous, id=5, tag

Use a persistent notification to allow the user to return to running Android app

南笙酒味 提交于 2019-11-30 07:12:05
I am developing an app with numerous Activities. I would like to create a persistent notification that (more or less) says, "AppName - Return to AppName" that will be present whenever my background services are running. Creating and disposing of the notification was no problem. Now, the user could be on any of several screens/Activities, leave the application, then want to re-enter the app via the notification. The problem is , the notification must have an intent, which launches a predetermined Activity . I want the notification to re-enter the app in whatever Activity is at the top of the

User Notifications - How to recover a lost notification_id from GCM?

安稳与你 提交于 2019-11-30 07:11:58
I generate notification_key s as described here . Suppose that due to some error I fail to store it, so I try to re-register. This time I receive a 400 error with the message "notification_key already exists" . This looks odd, especially compared to registration of a device to GCM , where you can register as many times as you want and always get the same Registration ID with status 200. Now I can't register again, and I also can't unregister, because I don't have the notification_id . Is there any way to get the previously generated notification_key from GCM? Or is the only way to register

Android Notification PendingIntent Extras null

隐身守侯 提交于 2019-11-30 07:02:53
问题 I am trying to send information from notification to invoked activity, while from my activity I got null. The code for notification is: private void showNotification() { Intent resultIntent = new Intent(this, MainActivity.class); if (D) Log.d(TAG, "Id: " + Id); resultIntent.putExtra("ineedid", deviceId); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(MeterActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent =

How to suppress notification on lock screen in Android 5 (Lollipop) but let it in notification area?

淺唱寂寞╮ 提交于 2019-11-30 06:49:55
After upgrade to Android 5.0 Lollipop it started showing automatically ongoing notification on lock screen. Sometimes users don't want to see all of them so they are asking developers how to let notification in status area but hide them on lock screen. Only way I found is to force users use screen lock (eg. Gesture or PIN) and programatically setVisibility() to VISIBILITY_SECRET . But not all them want to use screen lock. Is there any flag (or combination of flags) saying to notification: don't be visible on Lock screen but be visible in notification area? Use visibility and priority As

Android Notification Action is not fired (PendingIntent)

烈酒焚心 提交于 2019-11-30 06:36:26
I am trying to add an Notification action item in my app which is a music player. When a stream is started a notification should be triggered and an stop button for the stream should be displayed in the notfication. The notification working fine so far, I am having trouble with the stop action item. Here is how it is declared in the service starting the stream: Intent stopIntent = new Intent(this, MusicPlayerNew.class); stopIntent.putExtra("STOP", "STOP"); PendingIntent stopPendingIntent = PendingIntent.getActivity(this, 0, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT, null); mBuilder

Android call method on notification click

做~自己de王妃 提交于 2019-11-30 05:56:37
问题 This code creates a notification. If you click it, the current application is ran (the intent is created in Entry , which is my only Activity ), a slightly modified version of a Android Developers blog: private void makeIntent() { NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification note = new Notification(R.drawable.prev, "Status message!", System.currentTimeMillis()); Intent intent = new Intent(this, Entry.class); PendingIntent pi =