android-notifications

How to fix this bug : “android.app.RemoteServiceException: Bad notification posted from package”

旧城冷巷雨未停 提交于 2019-11-29 06:53:31
问题 The crash info is : android.app.RemoteServiceException: Bad notification posted from package com.xx.xx: Couldn't create icon: StatusBarIcon(pkg=com.xx.xx user=0 id=0x7f02035c level=0 visible=true num=0 ) android.app.ActivityThread$H.handleMessage(ActivityThread.java:1372) android.os.Handler.dispatchMessage(Handler.java:102) android.os.Looper.loop(Looper.java:136) android.app.ActivityThread.main(ActivityThread.java:5139) java.lang.reflect.Method.invokeNative(Native Method) java.lang.reflect

Android Notification Action is not fired (PendingIntent)

喜你入骨 提交于 2019-11-29 06:17:47
问题 I am trying to add an Notification action item in my app which is a music player. When a stream is started a notification should be triggered and an stop button for the stream should be displayed in the notfication. The notification working fine so far, I am having trouble with the stop action item. Here is how it is declared in the service starting the stream: Intent stopIntent = new Intent(this, MusicPlayerNew.class); stopIntent.putExtra("STOP", "STOP"); PendingIntent stopPendingIntent =

How to suppress notification on lock screen in Android 5 (Lollipop) but let it in notification area?

两盒软妹~` 提交于 2019-11-29 06:16:02
问题 After upgrade to Android 5.0 Lollipop it started showing automatically ongoing notification on lock screen. Sometimes users don't want to see all of them so they are asking developers how to let notification in status area but hide them on lock screen. Only way I found is to force users use screen lock (eg. Gesture or PIN) and programatically setVisibility() to VISIBILITY_SECRET. But not all them want to use screen lock. Is there any flag (or combination of flags) saying to notification: don

Building an Android notification server

这一生的挚爱 提交于 2019-11-29 05:10:22
Is there any documentation on how to build a custom notification server for Android? I am currently using GCM but due to the nature of the app and the fact that notifications are a very important feature in my app, I would rather implement this service internally so that I can control the throughput and not have any artificial limitations (even if it's hundreds of thousands of notifications per day). I also would like to use the same notification server later on with the iOS version of the app and for that reason, a custom built notification server is much preferred. I would ideally like to

How to get text of Stacked Notifications in Android

我只是一个虾纸丫 提交于 2019-11-29 04:09:23
The question is how to get the TEXT (not title) field of all incoming notifications when they get stacked (like in Whatsapp). public class NLService extends NotificationListenerService { public void onNotificationPosted(StatusBarNotification sbn) { Log.v(Constants.TAG_notifs, "------------------------- in onNotificationPosted(), Notification Text = " + sbn.getNotification().tickerText); Bundle extras = sbn.getNotification().extras; if (extras.containsKey("android.text")) { if (extras.getCharSequence("android.text") != null) { String text = extras.getCharSequence("android.text").toString(); Log

Android Notification PendingIntent Extras null

只谈情不闲聊 提交于 2019-11-29 02:50:19
I am trying to send information from notification to invoked activity, while from my activity I got null. The code for notification is: private void showNotification() { Intent resultIntent = new Intent(this, MainActivity.class); if (D) Log.d(TAG, "Id: " + Id); resultIntent.putExtra("ineedid", deviceId); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(MeterActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); // Bundle tmp = resultIntent

Custom notification sound , android Oreo?

谁说胖子不能爱 提交于 2019-11-29 02:06:35
I want to set a custom notification sound from a raw mp3 or wav file in my app. Below is my code private void sendMyNotification(String message) { Intent intent; if (sharedPreferences.getBoolean(SPConstants.IS_LOGGED_IN, false)) { intent = new Intent(this, ActivityNotification.class); } else { intent = new Intent(this, ActivitySplash.class); } intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); soundUri = Uri.parse(

Changing notification icon background on Lollipop

*爱你&永不变心* 提交于 2019-11-29 01:23:28
问题 I was going through the Notifications design pattern, and didn't find anything that talks about notification icon background. As you probably noticed, there is only a light grey background for custom notifications. But apps like Hangouts, or simply the USB Debugging notification has a custom color for their notification icon background. Is there any possibility to change that grey into something else? (that specific circle's color programmatically) 回答1: 1) Obtain Color int color = 0xff123456;

See notification of other app

我的梦境 提交于 2019-11-29 00:40:20
What API I should use for my app to see if I've received a notification from example from facebook, and so write in one textbox "Facebook!"? Your best bet is to use NotificationListenerService , which was added in API level 18. Here's an example: public class FacebookNotificationListener extends NotificationListenerService { @Override public void onNotificationPosted(StatusBarNotification sbn) { final String packageName = sbn.getPackageName(); if (!TextUtils.isEmpty(packageName) && packageName.equals("com.facebook.katana")) { // Do something } } @Override public void onNotificationRemoved

Perform Action On Button Click in Custom Notification : Android

安稳与你 提交于 2019-11-29 00:37:10
I am trying to perform some action like pause music , play music on button click of a custom notification in android. Currently I am doing it in this way , int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, "Custom Notification", when); NotificationManager mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.layout); contentView.setTextViewText(R.id.textView1, "Custom notification"); contentView.setOnClickPendingIntent(R