android-notifications

How to collapse multiple notifications into a single one using Firebase?

浪尽此生 提交于 2019-12-04 05:14:29
问题 I have function in Firebase Cloud Functions which is used to send notifications to specific users within my app and has as the notificationContent the following code: const notificationContent = { notification: { title: "My Notification Title", body: "My Notification Body", icon: "default", sound : "default" } }; I have tried to use collapse_key: "unique_key" but it has no effect. I read the has an effect only when the device is offline. I also have used a tag: "unique" but every time a new

Notification action button does not fire pending intent

邮差的信 提交于 2019-12-04 03:41:58
问题 I try to send intent to BroadcastReceiver from notification action button my problem is that when I click the button the intent in not fired or not getting to the BroadcastReceiver. Here is my code: The notification: Intent accept = new Intent(this, ChallengesActionReceiver.class); accept.setAction("com.soinfit.utilities.CHALLENGE_CLICK"); accept.putExtra("reqId", extras.getString("reqId")); accept.putExtra("answer", "1"); PendingIntent acceptIntent = PendingIntent.getActivity(this, 1, accept

How to set a bigger icon in Firebase app notification?

半世苍凉 提交于 2019-12-04 03:14:00
Hi i am implementing Push Notifications in Android using Firebase. Now, there is a small icon showing inside one circle. I need it to show in bigger size. Please see the image. And here is my code, android:id="@+id/relativeNotification" android:layout_width="192dp" android:layout_height="192dp" android:layout_alignParentEnd="true" android:layout_alignParentRight="true"> <com.inspius.coreapp.widget.TintableImageView android:layout_width="192dp" android:layout_height="192dp" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_gravity="center_vertical"

How to display multiple notification as a group?

人走茶凉 提交于 2019-12-04 03:06:45
here is my code for notification. it generate a new notification each time Random random = new Random(); int m = random.nextInt(9999 - 1000); NotificationCompat.Builder mBuilder =new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.quemark1) .setContentTitle("New Message") .setContentText(message) Intent intent = new Intent(this, ActivityMain.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(ActivityMain.class); stackBuilder.addNextIntent(intent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent

How to use NotificationCompat.Builder and startForeground?

时光怂恿深爱的人放手 提交于 2019-12-04 01:37:04
Short question: I'm trying to use the NotificationCompat.Builder class in order to create a notification that will be used for the service, but for some reason, i either don't see the notification, or can't cancel it when the service should be destroyed (or stopping from being in the foreground) . my code: @Override public int onStartCommand(final Intent intent, final int flags, final int startId) { final String action = intent == null ? null : intent.getAction(); Log.d("APP", "service action:" + action); if (ACTION_ENABLE_STICKING.equals(action)) { final NotificationCompat.Builder builder =

Android - show animated status bar icon

十年热恋 提交于 2019-12-04 01:13:31
问题 I'm trying to set my notification status bar icon as animated android.R.drawable.stat_sys_upload, it works fine, but the icon do not animate: private void showStatusNotification() { NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Builder notificationBuilder = new NotificationCompat.Builder(this); notificationBuilder.setAutoCancel(false); notificationBuilder.setOngoing(true); notificationBuilder.setContentIntent(PendingIntent

How to correctly handle startForegrounds two notifications

我是研究僧i 提交于 2019-12-04 01:00:01
问题 I have an IntentService that uploads a file. Everything works fine, but I'm a little confused about how to handle the notifications. When I start the notification I use startForeground() because the files can be rather large and I don't want the upload to get killed unless absolutely necessary. When I use startForeground() it displays two notifications in the notification area (one under Ongoing and one under Notifications): I've read through a number of different Stack Overflow posts and web

How to be notified when screen pinning is turned off in Android 5.0 Lollipop?

独自空忆成欢 提交于 2019-12-03 17:34:14
I have an app that runs in the background and starts an activity when a certain event occurs on the phone. I'm finding with Android 5.0 that when the user has screen pinning turned on with another app, the startActivity(intent) call is ignored completely. My app doesn't know that the activity didn't start, so the user then won't have another chance to see the activity until they manually reopen my app. Is there any sort of event I can register for to be notified when screen pinning is turned off, so I can reattempt to start my activity? Here is method in ActivityManager class which tells

Android get current song playing and song changed events, like Musixmatch

耗尽温柔 提交于 2019-12-03 17:33:32
What i want to achieve is very similar to what Musixmatch is doing. I need to be informed when the music starts playing and when the song is changed. All this in the service because my app may be closed (even musicmatch does this). In the above case even if Musixmatch app is not running i get a notification when ever i change the song on spotify or any player. Can anyone pls tell me how to achieve this. I don't need the code help, just what to know how to achieve it. I'm really confused how Musixmatch is doing it. Here is a solution to find if music player is playing. AudioManager manager =

Putting controls inside a notification in Android

a 夏天 提交于 2019-12-03 17:12:32
The Spotify Android app has music controls put in the notification (play/pause, next song). I would like to let the user control a Service from a controls inside notification. How do I do that? For this you need to make your own layout for Notification. Can you try with below code. First create an xml for your notification. custom_notification.xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" > <ImageView android:id="@+id/image" android:layout