私は本当に私のAndroidアプリケーションを進めています。onDestroy() and onPause()
ルーチンを実装できました。
また、Androidの通知サービスを取得して、タイトルと本文のアイコンを通知バー/タスクメニューに配置することもできました。
この通知サービスの唯一の問題は、Android アプリが既に実行されていて、ユーザーが通知をタップするとアプリの新しいインスタンスが表示されるonPause()
機能を開始した場合です。super.onPause(); moveTaskToBack(true);
ユーザーが新しいインスタンスを操作すると、バックグラウンド バージョンが既に実行されているため、プログラムがクラッシュし、競合が発生します。
これが私の通知コードです。このコードが私のアプリの既に実行されているバージョンを探すのに助けが必要です:
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificatonManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.ic_launcher;
CharSequence tickerText = "app name";
long when = System.currentTimeMillis();
CharSequence contentTitle = "app title";
CharSequence contentText = "text";
Intent notificationIntent = new Intent(this, SuperMicProActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
final int signed = 1;
mNotificatonManager.notify(signed, notification);
私が探していたonResume()
のは、ある種のbringTaskToFront(this)
オプションかもしれません。これは存在しますか?
ありがとう、