私はアプリを作っています。バックグラウンドで何らかのアクションを実行し、特定のケースでローカル通知を送信します。Xamarin c#Android通知をバックグラウンドで再開
今、通知をクリックするとアプリを再開します。
ここでStackOverflowで3つのスレッドを見て、フラグを試しましたが、誰も働いていませんでした。
通知をクリックますIntent resultIntent = new Intent(this, typeof(MainActivity));
TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this);
stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
stackBuilder.AddNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.GetPendingIntent(0, (int)PendingIntentFlags.CancelCurrent);
Notification.Builder builder = new Notification.Builder(this)
.SetContentTitle("Nuove Richieste")
.SetContentText("Hai nuove richieste da visionare")
.SetContentIntent(resultPendingIntent)
.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate)
.SetSmallIcon(Resource.Drawable.add)
.SetPriority(1);
Notification notification = builder.Build();
NotificationManager notificationManager =
GetSystemService(Context.NotificationService) as NotificationManager;
const int notificationId = 0;
notificationManager.Notify(notificationId, notification);
、黒い画面が現れ、何が間違っている:
これは私が試した何ですか?
おかげ
EDIT:
問題は別であり、さらに活動を再開についてですが、問題が異なります。
私は、データベースクエリごとに10秒をperfmorming TIMERをしました。このタイマーが強制終了されないと、新しいアクティビティーを表示する(または古いアクティビティーを再開する)方法がありません。私は通知を作成するときにタイマーを簡単に殺すことができるので、問題は解決されます。
ところで、通知はありませんが問題ない場合は問題です。私は別の質問を開きます。
ありがとうございました!
申し訳ありません、私は今、私のアプリで別の大きな問題を見た!私は編集で説明します。 – Raikoug