【发布时间】:2016-02-04 07:09:59
【问题描述】:
如何获得提醒通知。使用下面的代码,我只能在状态栏上看到三个点,在通知栏中看到一个通知。
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 , intent,PendingIntent.FLAG_ONE_SHOT);
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.bip);
Uri defaultSoundUri=RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.bip)
.setContentTitle("Temp")
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentText(message)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
【问题讨论】:
-
好吧,这很愚蠢。需要设置选择我的应用程序并更改应用程序通知设置。之后可以看到抬头通知。但是 facebook 和其他应用程序如何在没有这些设置的情况下搞砸。
-
我假设您使用的是中国制造的手机。网上流传的迹象表明,这些对通知设置有限制,其他手机制造商不得将其放在他们的设备上。一些应用程序被列入白名单,可能是基于它们的受欢迎程度,很可能是基于手机制造商和应用程序提供商之间的付费协议。毕竟,这对手机制造商来说是一个额外的收入来源,就像预装的应用程序一样。
标签: java android android-intent push-notification