0
我試圖用PutExtra & GetIntExtra,但通知ID總是被最後通知覆蓋,所有的通知值是一樣的。請告訴我如何解決它,Xamarin Android Wear:獲取當前點擊通知ID
在此先感謝!
Intent actionIntent = new Intent(this, typeof(ConfirmActivity));
actionIntent.PutExtra("NOTIFY_ID", 1);
PendingIntent actionPendingIntent = PendingIntent.GetActivity(this, 0, actionIntent, PendingIntentFlags.UpdateCurrent);
NotificationCompat.Action action = new NotificationCompat.Action.Builder(Resource.Drawable.ic_done_white_64dp_1x,
this.Resources.GetString(Resource.String.confirm), actionPendingIntent)
.Build();
var notification = new NotificationCompat.Builder(this)
.SetContentTitle("1111")
.SetContentText("1111111111111111111111")
.SetSmallIcon(Resource.Drawable.Icon).Extend(new NotificationCompat.WearableExtender().AddAction(action)).Build();
var manager = NotificationManagerCompat.From(this);
manager.Notify(1, notification);
Intent actionIntent2 = new Intent(this, typeof(ConfirmActivity));
actionIntent2.PutExtra("NOTIFY_ID", 2);
PendingIntent actionPendingIntent2 = PendingIntent.GetActivity(this, 0, actionIntent2, PendingIntentFlags.UpdateCurrent);
NotificationCompat.Action action2 = new NotificationCompat.Action.Builder(Resource.Drawable.ic_done_white_64dp_1x,
this.Resources.GetString(Resource.String.confirm), actionPendingIntent2)
.Build();
var notification2 = new NotificationCompat.Builder(this)
.SetContentTitle("2222")
.SetContentText("22222222222222222222")
.SetSmallIcon(Resource.Drawable.Icon).Extend(new NotificationCompat.WearableExtender().AddAction(action2)).Build();
manager.Notify(2, notification2);
=================================
[Activity(Label = "ConfirmActivity")]
public class ConfirmActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Confirm);
Intent intent = this.Intent;
int NOTIFY_ID = intent.GetIntExtra("NOTIFY_ID", 0); //always 2
}
}
謝謝,我發現這個問題是,我沒有使用唯一的請求碼。 – Aaron