0

ステータスバーのアプリ通知アイコンをクリックするたびにカスタムダイアログボックスがポップアップするようにしようとしています。しかし、私はそれを機能させることができません。これが私の通知アイコンコードです。また、クリックするたびにメインアクティビティに戻りたくありません。

    NotificationManager nm=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification=new Notification(R.smiley_face, "Lala", System.currentTimeMillis());
    Context context=MainActivity.this;
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), Notification.FLAG_ONGOING_EVENT);        
    notification.flags = Notification.FLAG_ONGOING_EVENT;
    notification.setLatestEventInfo(this, "Smiley", "Touch for more options", contentIntent);
    Intent intent=new Intent(context,MainActivity.class);
    PendingIntent  pending=PendingIntent.getActivity(context, 0, intent, 0);
    nm.notify(0, notification);

カスタム ダイアログ コードは次のとおりです。通知アイコンコードに入れてみましたが、うまくいきません。

                CustomDialogClass cdd = new CustomDialogClass(MainActivity.this);
        cdd.show();

解決済み

私がやったのは、カスタムダイアログを透明なアクティビティにしてから、インテントとして開始することだけでした。

4

1 に答える 1

0

このタグを使用して、アクティビティをダイアログとして開きます

<activity android:theme="@android:style/Theme.Dialog">
于 2013-11-20T18:42:57.630 に答える