android-notifications

Bad Notification: Couldn't expand RemoteViews for: StatusBarNotification. on Android Nougat

混江龙づ霸主 提交于 2019-12-09 09:04:05
问题 I use OneSignal SDK to show notifications. I do it in OneSignalPushService.java . OneSignalPushService.java: public class OneSignalPushService extends NotificationExtenderService { @Override protected boolean onNotificationProcessing(OSNotificationReceivedResult notification) { if (!TinyDbWrap.getInstance().isPushEnabled()) { KLog.d(this.getClass().getSimpleName(), "Notification will not displayed"); return true; } OverrideSettings overrideSettings = new OverrideSettings(); overrideSettings

Couldn't expand RemoteViews

懵懂的女人 提交于 2019-12-09 08:27:43
问题 I try to create a custom notification but getting the following exception: FATAL EXCEPTION: main android.app.RemoteServiceException: Bad notification posted from package com.my.app: Couldn't expand RemoteViews for: StatusBarNotification(pkg=com.my.app user=UserHandle{0} id=1 tag=null score=0: Notification(pri=0 contentView=com.my.app/0x7f03001b vibrate=null sound=null defaults=0x0 flags=0x2 kind=[null])) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1423) at android.os

In Android how can i know the current notification id to clear the notification

放肆的年华 提交于 2019-12-09 06:37:56
问题 Now in android i put this code in one activity to show notification when a button pressed. static int notificationCount = 0; then btnNotification.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent notificationIntent = new Intent(AlertsActivity.this,NotificationActivitty.class); PendingIntent pIntent = PendingIntent.getActivity(AlertsActivity.this,notificationCount,notificationIntent,Intent.FLAG_ACTIVITY_NEW_TASK); // Construct the notification

Custom notification sound not playing

流过昼夜 提交于 2019-12-09 06:02:42
问题 I'm trying to make a custom sound play on a status bar notification. The .mp3 file is in res/raw/ . But when I notify the user the sound is not played. I've tryied with MediaPlayer, and it works, but I dont want to make it play with MediaPlayer. Here is my method: public void showNotification() { String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); int icon = R.drawable.feedback; // icon from resources CharSequence

Firebase(FCM) notifications not coming when android app removed from recent tray

孤人 提交于 2019-12-09 05:39:29
问题 I'm sending Firebase notifications through my own webservice with PHP like below. $url = 'https://fcm.googleapis.com/fcm/send'; $fields = array( 'registration_ids' => $tokens, 'data' => $message ); $headers = array( 'Authorization:key = SERVER_KEY ', 'Content-Type: application/json' ); 1.Notifications are coming when App is in Foreground and Background without any issues , But if I removed app from recent tray then notifications not coming , I must have to handle this any solution for this ?

Notification with “null” PendingIntent

折月煮酒 提交于 2019-12-09 04:18:26
问题 I'm trying to implement notification in Android. Now I have a problem, I don't want to have a PendingIntent that user will open any Activity . How can I do that? 回答1: PendingIntent contentIntent = PendingIntent.getActivity( getApplicationContext(), 0, new Intent(), // add this PendingIntent.FLAG_UPDATE_CURRENT); 回答2: The following works and seems more straightforward: PendingIntent pi = PendingIntent.getActivity(context, 0, null, 0); Having a notification without launching a subsequent

How to disable Home button without using the TYPE_KEYGUARD?

给你一囗甜甜゛ 提交于 2019-12-08 22:48:14
问题 i create a lockscreen application and i need to disable a home button, so if that phone is stolen, that phone can't be accessed.. my lockscreen is a fullscreen activity.. im use this code to disable a home button, but it gave me some bug. here's the code: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } @Override public void onAttachedToWindow() { this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);

My notification action icons don't be shown in android 7

五迷三道 提交于 2019-12-08 20:31:37
问题 My notification action icons don't be shown in android 7 (N)! Is it a change in Android 7? Can not I use them anymore? I see this problem when I run my app (That targeted API23) on Nexus 6P with Android 7. 回答1: Yes, Google redesigned notifications in Android 7 and abort icon for actions. You can also check this: https://developer.android.com/about/versions/nougat/android-7.0.html#notification_enhancements 来源: https://stackoverflow.com/questions/42082882/my-notification-action-icons-dont-be

Can we have Custom Notification for android.os.DownloadManager?

六月ゝ 毕业季﹏ 提交于 2019-12-08 19:26:51
问题 Currently I am using below code snippet to download a file using DownloadManager: String servicestring = Context.DOWNLOAD_SERVICE; DownloadManager downloadmanager; downloadmanager = (DownloadManager) getSystemService(servicestring); Uri uri = Uri .parse("some url here"); DownloadManager.Request request = new Request(uri); Using this code I am getting below notification. My question is, can we add some cross button in this notification so that if user click that button it will cancel download

NotificationCompat.BigTextStyle Content disappears on new notification

耗尽温柔 提交于 2019-12-08 18:06:36
问题 String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) this.getSystemService(ns); int icon = R.drawable.ic_launcher; CharSequence tickerText = title; long when = System.currentTimeMillis(); Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); if(alarmSound == null){ alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); if(alarmSound == null){ alarmSound = RingtoneManager.getDefaultUri