android-notifications

Clicking Android Notification Actions does not close Notification drawer

怎甘沉沦 提交于 2019-11-27 10:43:48
问题 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

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

时光毁灭记忆、已成空白 提交于 2019-11-27 10:36:05
问题 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

Large notification icon background

房东的猫 提交于 2019-11-27 10:20:31
问题 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? 回答1: 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

PendingIntent is not working on Android O

落花浮王杯 提交于 2019-11-27 09:31:20
I have download notification in my application. I've added "Cancel" button to NotificationCompat.Builder by calling addAction() method. But button not working on Android O device. When I press "Cancel" button nothing happens. But button working on Android < O. My Notification : NotificationCompat.Builder notification = new NotificationCompat.Builder(context, channelId) .setContentTitle(title) .setSmallIcon(R.drawable.network_download) .setContentText(contentText) .setOngoing(true) .setContentIntent(null) .addExtras(idBundle) .addAction(R.drawable.cancel, context.getString(R.string.cancel),

Click on the Notification programmatically

余生颓废 提交于 2019-11-27 09:22:17
I trying click on the notification after receiving it. I'm able to drag the notification drawer using the Accessibility service. For clicking the notification I'm using accessibilityEvent.getSource() and accessibilityNodeInfo.performAction(AccessibilityNodeInfo.ACTION_CLICK); My code: public class MyAccessibilityService extends AccessibilityService { /** * On receiving the AccessibilityEvent performs the Actions * * @param event */ @Override public void onAccessibilityEvent(AccessibilityEvent event) { Log.i(TAG, "Get the Accessibility Event"); if (event.getEventType() == AccessibilityEvent

GCM Push Notification Not Revived

非 Y 不嫁゛ 提交于 2019-11-27 08:41:11
问题 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=

Different text for the wear device and the mobile device

僤鯓⒐⒋嵵緔 提交于 2019-11-27 08:19:04
问题 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? 回答1: 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

Android notification with buttons on it

帅比萌擦擦* 提交于 2019-11-27 07:01:05
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)? LiTTle 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_layout is from step 1 RemoteViews contentView=new RemoteViews(ctx.getPackageName(), R.layout

Turn off notifications of an app programatically on Android

淺唱寂寞╮ 提交于 2019-11-27 06:54:40
问题 I am developing a package manager application which shows checkboxes to turn off notifications from different applications installed on the Android device. Since Android 4.1, users can turn off notifications of an app from application manager. Can I turn on/off notifications from an app programatically? Is there an API for doing that? 回答1: No, you cannot do that from your code. Perhaps on rooted devices you could do some magic, but that shall not really count for wider audience. 回答2: If you

Is setContentIntent(PendingIntent) required in NotificationCompat.Builder?

此生再无相见时 提交于 2019-11-27 06:53:07
问题 Calling : public static void triggerTestNotification(Context ctx, String tag, int id) { Notification not = new NotificationCompat.Builder(ctx) .setContentTitle("Title").setContentText("Text") .setAutoCancel(true) // cancel on click .setSmallIcon(R.drawable.ic_launcher).build(); NotificationManager notificationManager = (NotificationManager) ctx .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(tag, id, not); } in onCreate() of my main activity yields : 11-17 15:58:46