android-notifications

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

…衆ロ難τιáo~ 提交于 2019-11-29 13:00:09
问题 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 回答1: Check out the answer here: How to give counter if more than one

Show Badge count on App icon in Android

拟墨画扇 提交于 2019-11-29 12:58:40
In my Android app,i want to show a push-notification badge count into application icon like ios. How can I show badge count into application icon ? Android doesn't have this particular feature. An alternative might be to have a notification that displays the number but the app icon itself is incapable under normal circumstances. If you REALLY wanted to break design guidelines you could make a widget that looks like your app icon and the widget gets much more control over how it's drawn. Some apps have been released to do this for Gmail, Google Voice, the standard Messaging app, and missed

Single Notification for multiple Foreground Services using startForeground() call

北城余情 提交于 2019-11-29 12:06:07
问题 I have an app that has two services. One is for showing UI for floating (overlay) on other apps using WindowManager . The other is for Location Tracking using GooglePlayAPI . My app always runs these services. I want these services not to be killed by the OS. So I call Service.startForeground() . However there are two notifications in the notification drawer. Is there a way to use a single notification for both services? 回答1: Yes, it is possible. If we take a look at Service.startForeground()

Notification action button not clickable in lock screen

☆樱花仙子☆ 提交于 2019-11-29 11:24:48
In order to better support Android 5 notifications, I am now setting my app's notification visibilty to "public". After considering the answers on Lollipop Notification setVisibility() Does Not Work? , the notification is now displayed as expected. However, when I want to click the action button of the notification, I first have to unlock the device which should not be required. (The action shows that a password database is unlocked and the action button will lock the database.) This is the code I am using the creating the notification (using Xamarin's Mono for Android): NotificationCompat

Android Wear - start wear activity from handheld action

别说谁变了你拦得住时间么 提交于 2019-11-29 11:04:55
I'm sending a notification from an android handheld device to an android wear device. I'd like to include an action with the notification that starts an activity on the android wear device. How do I set the pending intent to an activity on the wear device? I'm able to launch the activity if the notification is created on the wearable, but not if the notification is created on the phone and then sent to the wearable. // creating action for push notification created on handheld public NotificationCompat.Action CreateWearAppAction(Integer metricId) { // I wasnt able to look up the wear's main

java.lang.NoSuchMethodError: android.app.Notification$Builder.addAction

被刻印的时光 ゝ 提交于 2019-11-29 10:39:55
I have developed an android application where i have used notification to be displayed when the application starts The application works perfect when i run the code on android emulator where as when i try to run the same on real device which has android version of 4.0.4 It throws me error in the logcat as 05-13 19:06:45.824: E/AndroidRuntime(15402): FATAL EXCEPTION: main 05-13 19:06:45.824: E/AndroidRuntime(15402): java.lang.NoSuchMethodError: android.app.Notification$Builder.addAction 05-13 19:06:45.824: E/AndroidRuntime(15402): at com.example.gpstracker.MainActivity.onCreate(MainActivity

Android - Clear task flag not working for PendingIntent

旧街凉风 提交于 2019-11-29 09:20:13
I have a task stack of A > B > C. I am currently on C, and then I press the home button. I get a notification with the intent to take me to Activity A. I press the notification, and I'm at A but if I press back, I go to C, then B, then A. I am setting up my PendingIntent like so. Anything clearly wrong with it? final Intent notificationIntent = new Intent(mContext, ActivityA.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(myContext, 0, notificationIntent, 0); EDIT 1: I tried the

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

你。 提交于 2019-11-29 09:11:51
问题 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

Default notification background color

帅比萌擦擦* 提交于 2019-11-29 07:40:24
I have a custom notification that uses a LinearLayout that contains an ImageView and a TextView . Before Android 4.0 all I needed to do was swap out the text colors with the EventContent and EventContent.Title styles and all the colors looked great. But on Android 4.0 (Ice Cream Sandwich) my custom notification background color is a light gray, and to make matters worse it clashes horribly with the default text styles. This is strange to me, since all the other notifications have a dark-gray (almost black) color, and I haven't changed the background color at all in my layout. Is there a way to

Create an Android notification with expiration date

醉酒当歌 提交于 2019-11-29 07:22:54
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. Karakuri 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 notification. (If the notification is no longer there, then the call to cancel will do nothing.) /