私はタイマーアプリケーションのように作成しています。タイマーを開始すると、Androidホームに移動するか他のアクティビティを開始するオプションがあります。
タイマーを開始するときに通知バーアイコンを設定し、他のアプリケーションを使用する場合(開始したタイマーアクティビティから移動することを意味します)、通知アイコンをクリックして以前に開始したタイマーアクティビティに戻る必要があります???
クリックすると、以前に開始されたタイマーアクティビティではなく、新しいインスタンスタイマーアクティビティが開始されます。、次に戻るボタンをクリックすると、以前のタイマーアクティビティが表示されます。
質問は次のとおりです。通知バーを介して以前に開始したアクティビティを呼び出す方法、そのアクティビティの新しいインスタンスを開始しない方法??
これは以下の私のコードのサンプルです:
private void notificationBar()
{
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.ico;
CharSequence tickerText = "some title...";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
Context context = getApplicationContext();
CharSequence contentTitle = "some app title";
CharSequence contentText = "...some info !";
Intent notificationIntent = new Intent(this, main.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | Notification.FLAG_AUTO_CANCEL);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(NOTIF_ID, notification);
}
private void notificationClose(int notifID)
{
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
mNotificationManager.cancel(notifID);
}