0

説明: デーモン スレッドを使用しました。私のアプリケーションでは、ユーザーが任意のファイル (.jpg、.txt、.pdf など) を送信すると、ファイルごとに個別の通知が生成されます。3つの通知があるとします。ユーザーがいずれかの通知をタップするとandroid.content.Intent.ACTION_VIEW、ファイルに従って通知が呼び出され、openwith オプションが提案されます。

問題: ユーザーが通知を選択すると、それぞれのアプリケーションで開かれます (たとえば、ユーザーが sample.txt を選択すると、それは colornote で開かれます)。その後、ユーザーが別の通知をタップすると、何もせず、それ以降は同じことが起こります。

通知用の一意の ID も渡しました..!

 long timestamp=System.currentTimeMillis();

 int i=(int) timestamp;

 mNotificationManager.notify(i, mBuilder.build());

エラーを見つけるのを手伝ってください。

4

1 に答える 1

2

PendingIntent通知ビルダーに追加する必要があります。

TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(MyActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
        stackBuilder.getPendingIntent(
            0,
            PendingIntent.FLAG_UPDATE_CURRENT
        );
mBuilder.setContentIntent(resultPendingIntent);

この記事を読む:簡単な通知の作成

于 2013-02-28T14:03:07.697 に答える