android-notifications

Notification passes old Intent Extras

眉间皱痕 提交于 2020-01-18 19:38:38
问题 i am creating a notification inside a BroadcastReceiver via this code: String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); int icon = R.drawable.ic_stat_notification; CharSequence tickerText = "New Notification"; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); notification.defaults |= Notification.DEFAULT_VIBRATE; long[] vibrate = {0,100,200,200

Notification passes old Intent Extras

[亡魂溺海] 提交于 2020-01-18 19:37:57
问题 i am creating a notification inside a BroadcastReceiver via this code: String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); int icon = R.drawable.ic_stat_notification; CharSequence tickerText = "New Notification"; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); notification.defaults |= Notification.DEFAULT_VIBRATE; long[] vibrate = {0,100,200,200

Notification passes old Intent Extras

自作多情 提交于 2020-01-18 19:37:00
问题 i am creating a notification inside a BroadcastReceiver via this code: String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); int icon = R.drawable.ic_stat_notification; CharSequence tickerText = "New Notification"; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); notification.defaults |= Notification.DEFAULT_VIBRATE; long[] vibrate = {0,100,200,200

App crashes onResume when canceling Notification

蹲街弑〆低调 提交于 2020-01-16 01:55:06
问题 I try to cancel my Notification in onResume() but it crashes: With displayNotification() i create the Notification. I also tried to set the cancelNotification() in a try catch. But this doesn't solve the problem. But without i can't even start the app to generate the Notification. Here are my Codesnippets: OnResume: @Override protected void onResume() //activity was resumed and is visible again { Log.d(logtag,"onResume() called"); super.onResume(); cancelNotification(); } cancelNotification()

Parse Receiver android code after sending push from php

给你一囗甜甜゛ 提交于 2020-01-16 01:10:16
问题 I have a PHP code to send push notification, PHP script returns `{"result":true} but its not displayed on the device. I think I need to write a custom receiver code. I have the Receiver class as: package com.phpand; import org.json.JSONException; import org.json.JSONObject; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.util.Log; public class ParseReceiver extends BroadcastReceiver { private

Notification doesn't show up if only large icon is set

寵の児 提交于 2020-01-16 00:14:05
问题 I want to add a large icon to my notification, but when I run the app, the notification doesn't show up. When I change to small icon, it works but icon is too small. Below is my code, any help where it is wrong? Bitmap rawBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setLargeIcon(rawBitmap) .setContentTitle("Alert") .setContentText("CITRUS PUNCH Minute Maid expired");

GCM update 7.5 to 8.3.0 fatal exception

走远了吗. 提交于 2020-01-14 14:06:47
问题 I tried to update the GCM services (Google cloud messages) libraries (from 7.5 to 8.3.0) in my Gradle project. But now, with this new version, i'm unable to launch my previous activity which was working perfectly before. The code which handle the following error is : Intent in = new Intent(this, MyGcmListenerService.class); startService(in); MyGcmListenerService.java : public class MyGcmListenerService extends GcmListenerService { private static final String TAG = "MyGcmListenerService";

Cannot resolve PendingIntent.getActivity()

笑着哭i 提交于 2020-01-14 09:34:08
问题 I am trying to make a custom notification and cannot resolve this. public void remNotifyClicked (View view){ notification.setSmallIcon(R.drawable.ic_launcher); notification.setTicker("Ticker"); notification.setContentTitle("Notification"); notification.setContentText("Congratulation!"); notification.setWhen(System.currentTimeMillis()); Intent i = new Intent(this, SecondActivity.class); notification.setContentIntent( new PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT))

How to use NotificationCompat.Builder and startForeground?

廉价感情. 提交于 2020-01-12 14:07:51
问题 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

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

烈酒焚心 提交于 2020-01-12 09:52:16
问题 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