android-notifications

How to cancel a foreground service from using the notification (swipe dismiss) or clear all notifications?

情到浓时终转凉″ 提交于 2019-11-28 22:46:15
问题 I'm currently creating a foreground service with a notification that appears in the notification bar when the service starts. If the service stops, the notification dismisses. My question is, is there a way to stop the service when "clear all notifications" or a dismiss of the notification (swipe) occurs? Updated to include implementation of notification: public int onStartCommand(Intent intent, int flags, int startId) { Log.d(CLASS, "onStartCommand service started."); if (getString(R.string

How to check if my app is allowed to show notification

亡梦爱人 提交于 2019-11-28 22:44:20
In Android settings users can turn off notification if they don't want to. So is there any method that like isNotificationAllowed() to check is my app is allowed to show notification? And how to open android setting page to guide my users to turn on notification? EDIT - New Answer: Seems like google added the proper API call: NotificationManagerCompat.from(context).areNotificationsEnabled() OLD ANSWER: For anyone who is looking at this question, note that NotificationListenerService is different from "Show Notification". These two are different things ! If an app has access to

Why is this NotificationListenerService not working

北城余情 提交于 2019-11-28 20:43:46
I'm fighting against the NotificationListenerService without much luck. I tried a lot of recipes found here and there, especially on so... But it works quite inconsistently. A first look at the code : Manifest : <service android:name=".services.NLService" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" > <intent-filter> <action android:name="android.service.notification.NotificationListenerService" /> </intent-filter> </service> Then the service itself : public class NLService extends NotificationListenerService { private String TAG = "NLService"; // bind and unbind

Clicking Android Notification Actions does not close Notification drawer

匆匆过客 提交于 2019-11-28 18:33:37
I am adding a Notification to System bar using the NotificationCompat library. This Notification has two action buttons. Also, AutoCancel() property on the Notification is set to true. On Click of the action buttons, System is configured to launch an IntentService which calls NotificationManager.cancel(NOTIFICATION_ID) and then launches an Activity in a New Task. Problem is that though this call removes the notification from the tray, it does not collapse the drawer. The called Activity is drawn behind the drawer. Can someone please shed some light on what special code is need to close the

Firebase Cloud Messaging (FCM) - Launch Activity when user clicks the notification with extras

▼魔方 西西 提交于 2019-11-28 17:19:16
I'm trying to open a specific activity when the user clicks the notification, when the app is in the background, with some extra parameters. I'm using the click_action and it's working fine, the app opens the desired Activity. Now I need the server to pass an extra parameter, an id , to this Activity so I can present the desired details associated with the notification. Like an e-mail application, that when we click on the notification opens the details of that specif email. How can I do this? Ok, I have found the solution. This is the json that I'm sending from the server to the app {

Large notification icon background

核能气质少年 提交于 2019-11-28 17:16:08
Since Android 5.0 large icons in notifications have color background: For small icon, it is the accent color of notification ( Notification.Builder.setColor(int) ). How do I set it for large icon? Is it part of the actual image? If it is, what should the circle radius be? Yes, the color of the large icon is part of the actual image. The dimensions of the large icon on lollipop are 40x40dp with a optical view filling the entire image. So you should create an asset of 40x40dp with a circle of a 20dp radius. You can set the notification's large icon as follows: NotificationCompat.Builder mBuilder

How to Create a Reminder Notification

安稳与你 提交于 2019-11-28 16:23:41
问题 I have referred many sites but still I am not able to create the notification(reminder or alarm) I don't know exactly how to create and work with it. Its to notify/remind user about task and also provide daily tips to the user.. I will be glad to have your help in doing so and how to code it too... Regards:) Thanxs for your help in advance. 回答1: You need two things: AlarmManager: to schedule your notification at a regular bases (daily, weekly,..). Service: to launch your notification when the

GCM Push Notification Not Revived

霸气de小男生 提交于 2019-11-28 14:22:59
Below you can find the manifest file, is their anything wrong with configuration of GCM push notification classes ? no notification is received at all on android devices but apple devices receive the notification package="ac.iec" <uses-permission android:name="android.permission.WAKE_LOCK"/> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/> <permission android:name="ac.iec.permission.C2D_MESSAGE" android:protectionLevel="signature"/> <uses-permission android:name="ac.iec.permission.C2D_MESSAGE"/> <receiver android:name="com.google.android.gms.gcm.GcmReceiver" android

Different text for the wear device and the mobile device

五迷三道 提交于 2019-11-28 14:19:59
Is it possible to have a notification that shows a different text (content title and content text) in the Android wear device and in the mobile device? Not at the moment. However, you can achieve this effect in the following way: post a notification on the phone with setLocalOnly(true) post a DataItem using a DataAPI that describes the notification and changed text when the wearable receives the DataItem , post the notification with different text, again setting setLocalOnly(true) on each notification alse call setDeleteIntent so you know, when there are dismissed when on of the notifications

Android 4: can't dismiss notification by swiping

…衆ロ難τιáo~ 提交于 2019-11-28 11:10:49
I have some code that creates some notifications, it's really basic. int icon = R.drawable.notification; CharSequence tickerText = "Text"; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); Context context = getApplicationContext(); CharSequence contentTitle = "Text"; CharSequence contentText = "Text"; Intent notificationIntent = new Intent(this, RequestActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText,