主旋律后,即使单击通知后,删除的Android棒棒糖通知是发送通知,使用PushNotification可在店内的新的提议使用谷歌云消息甚至无法使用我的应用程序的AUTOCANCEL
private void sendNotification(Context context, String message) {
SharedPreferences mPrefs = getSharedPreferences("MYAPP", Context.MODE_PRIVATE);
int uniqueNumber = this.getSharedPreferences("MYAPP", Context.MODE_PRIVATE).getInt("uniqueNumber", 0);
Log.d("GCM: GN", "Message: " + message);
uniqueNumber = ++uniqueNumber;
int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
Intent intent = new Intent(GCMIntentService.this,OpenActivity.class);
intent.putExtra(OpenActivity.EXTRA_KEY, "navigate");
intent.putExtra(OpenActivity.GET_NOTIFY_ID_EXTRA, uniqueNumber);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
notification.setLatestEventInfo(context, title, message, pendingIntent);
notification.flags |= Notification.DEFAULT_LIGHTS|Notification.FLAG_AUTO_CANCEL ;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notificationManager.notify(uniqueNumber, notification);
SharedPreferences.Editor prefsEditor = mPrefs.edit();
prefsEditor.putInt("uniqueNumber", uniqueNumber);
prefsEditor.commit();
}
用户
伙计们,这段代码不适用于棒棒糖。
任何帮助赞赏...
是否有原因,您没有使用支持库的[NotificationCompat.Builder](http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html)甚至[Notification .Builder](http://developer.android.com/reference/android/app/Notification.Builder.html)?您使用的代码已过时4年。 – ianhanniballake
没有特别的原因。我以前使用过Notification.Builder,但我得到了同样的问题。 – saikiran
与我的应用程序中的NotificationCompat.Builder相同的问题。 – saikiran