4

Androidアプリ開発初心者です。私は最終年度のプロジェクトの申請を行っています。

私のアプリケーションは、ユーザーに予定を通知します。これまでのところ、予定日に通知バーにアラートを表示することができました。

私のスーパーバイザーは、ユーザーが通知バーのタブをタップすると、ダイアログ ウィンドウが表示され、詳細 (予定のタイトルと場所) が表示される機能の追加を要求しました。

どうすればこれを達成できますか?

4

1 に答える 1

5

これを試して:

Intent notifyIntent = new Intent(context,YourActivityClassHere.class);
notifyIntent.setFlag(Intent.FLAG_ACTIVITY_NEW_TASK);
//UNIQUE_ID if you expect more than one notification to appear
PendingIntent intent = PendingIntent.getActivity(SimpleNotification.this, UNIQUE_ID, 
            notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  1. PendingIntentでアクティビティの 1 つを開くようにする
  2. そのアクティビティを完全に透明にして、ダイアログを開きます。

通知クリックイベントからアクティビティを開く場合:

notifNotificationオブジェクトであると仮定します。

Intent notificationIntent = new Intent(this.getApplicationContext(), ActivityToStart.class);
PendingIntent contentIntent = PendingIntent.getActivity(this.getApplicationContext(), 0, notificationIntent, 0);
notif.contentIntent = contentIntent;

その他の支援については、このサンプル プロジェクトを表示できます。次のことが役立ちます。

于 2012-12-31T09:49:28.927 に答える