我在我的应用中使用android本地通知,一切正常, 但我的问题是:
有没有办法向特定用户或群组发送通知,或者向/从特定用户显示/隐藏通知?
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.SetAutoCancel(true) // Dismiss the notification from the notification area when the user clicks on it
.SetContentIntent(resultPendingIntent) // Start up this activity when the user clicks the intent.
.SetContentTitle("Button Clicked") // Set the title
.SetNumber(count) // Display the count in the Content Info
.SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Alarm))
.SetDefaults(0)
.SetSmallIcon(Resource.Drawable.notify)
.SetVibrate(new long[] { 1000, 1000 })
.SetContentText(String.Format("The button has been clicked {0} times.", count)); // the message to display.
// Finally, publish the notification:
NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
notificationManager.Notify(ButtonClickNotificationId, builder.Build());
答案 0 :(得分:0)
有没有办法向特定用户或群组发送通知,或者向/从特定用户显示/隐藏通知?
您需要使用UserManager来查询用户,但要使用该权限,您的应用需要MANAGE_USERS
权限,其权限级别为signature|system
,这意味着应用程序必须用平台密钥签名。您可以参考this case。