android-notifications

Music player control in notification

穿精又带淫゛_ 提交于 2019-11-26 12:02:14
问题 how to set notification with play/pause, next and previous button in android.! I am new with Android & also at stack overflow. So please bear with me. I set notification when song is start to play like below : ` @SuppressLint(\"NewApi\") public void setNotification(String songName){ String ns = Context.NOTIFICATION_SERVICE; NotificationManager notificationManager = (NotificationManager) getSystemService(ns); @SuppressWarnings(\"deprecation\") Notification notification = new Notification(R

How to fix: android.app.RemoteServiceException: Bad notification posted from package *: Couldn't create icon: StatusBarIcon

南楼画角 提交于 2019-11-26 11:12:48
I'm seeing the following exception in crash logs: android.app.RemoteServiceException: Bad notification posted from package com.my.package: Couldn't create icon: StatusBarIcon(pkg=com.my.package user=0 id=0x7f02015d level=0 visible=true num=0 ) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1456) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:146) at android.app.ActivityThread.main(ActivityThread.java:5487) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android

Do GCM registration id's expire?

為{幸葍}努か 提交于 2019-11-26 10:28:05
问题 I know that C2DM registrations expire, and you are supposed to periodically refresh the registration ID. Is this the case with GCM? by looking at the following code on the Android GCM guide (shown below), it seems like you only do it once and don\'t need to refresh, but I dont see that explicitly written anywhere, so I just wanted to check. final String regId = GCMRegistrar.getRegistrationId(this); if (regId.equals(\"\")) { GCMRegistrar.register(this, SENDER_ID); } else { Log.v(TAG, \"Already

Adding button action in custom notification

…衆ロ難τιáo~ 提交于 2019-11-26 10:27:33
I have made custom notification and there is a button in that, I want to perform two different functionalities on notification and button click . I look at many links but couldn't find the way to add button listener. Can anyone help. Here is my code. Thanks a lot. private void startNotification() { Intent intent; PendingIntent pIntent; RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.mynotification); Context context = getApplicationContext(); NotificationCompat.Builder builder = new NotificationCompat.Builder( this).setSmallIcon(R.drawable.ic_launcher).setContent(

Load image from url in notification Android

旧城冷巷雨未停 提交于 2019-11-26 10:20:52
问题 In my android application, i want to set Notification icons dynamically which will be loaded from URL. For that, i have used setLargeIcon property of NotificationBuilder in receiver .I reffered many link and tried various solutions but couldn\'t get desired output. Though i downloaded that image from url and setting that bitmap in notification, it is not being displayed. Instead it displays the setSmallIcon image as large icon. I don\'t know where i am going wrong. Here i am posting my code.

Open specific Activity when notification clicked in FCM

感情迁移 提交于 2019-11-26 09:37:57
问题 I am working on App in which I am required to show notification. For notification, i am using FireBase Cloud Messaging (FCM) . I am able to get Notification when app is in background. But when I click on notification, it redirect to home.java page. I want it to redirect to Notification.java page. So,please tell me how to specify Activity in on Click of notification. I am using two services: 1.) MyFirebaseMessagingService 2.) MyFirebaseInstanceIDService This is my code sample for

Update text of notification, not entire notification

≡放荡痞女 提交于 2019-11-26 09:25:41
问题 Prelude I\'m trying to add a chronometer on the notification. The chronometer is a service. Every second this line is called (continue Thread is a the \"running\" boolean, timeString is the elaborated String showing the time): NotificationChrono.updateNotification(getApplicationContext(), continueThread, NOTIF_ID, timeString, \"Chronometer\", notificationManager); This is the NotificationChrono class: public class NotificationChrono { static public void updateNotification(Context context,

Create Custom Big Notifications

ε祈祈猫儿з 提交于 2019-11-26 09:23:43
问题 I wanted to create a Notification including some controls. Since text and controls are small with default notification size (64dp), i wanted have it larger than default size. It is possible to create larger notifications, and I think it is possible to have a custom layout, too, but I don\'t know how. To be more specific, the following screenshot shows the notification from spotify (image take from here): As you can see, the size is bigger than default. Further, it has some kind of

How to dismiss notification after action has been clicked

寵の児 提交于 2019-11-26 08:58:55
问题 Since API level 16 (Jelly Bean), there is the possibility to add actions to a notification with builder.addAction(iconId, title, intent); But when I add an action to a notification and the action is pressed, the notification is not going to be dismissed. When the notification itself is being clicked, it can be dismissed with notification.flags = Notification.FLAG_AUTO_CANCEL; or builder.setAutoCancel(true); But obviously, this has nothing to with the actions associated to the notification.

Android 4.1: How to check notifications are disabled for the application?

核能气质少年 提交于 2019-11-26 08:51:00
问题 Android 4.1 offers the user a check box to disable notifications for a specific application. However, as a developer we have no way to know whether a call to notify was effective or not. I really need to check if the notifications are disabled for the current application but I can\'t find any setting for that in the API. Is there ever a way to check this setting in the code? 回答1: You can't 100% can't. It is asked in this Google I/O 2012 video and the Project lead for the new notifications