0

私はAndroidアプリケーションで通知を表示するために次のコードを使用していますが、これを使用すると、アクティビティも表示されます(つまり、黒い空白の画面)この画面は必要ありませんが、単純な通知とユーザーがクリックしたとき通知後、アクティビティを開始します。このコードに何をすべきですか?

        NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notify = new Notification(R.drawable.mcube_logo, "Message Sent", Calendar.getInstance().getTimeInMillis());

        Intent intent = new Intent(RecieveAlarm.this, otherActivity.class);
        PendingIntent pendingIntent =PendingIntent.getActivity(RecieveAlarm.this, 1, null, PendingIntent.FLAG_CANCEL_CURRENT);

        notify.setLatestEventInfo(RecieveAlarm.this, "Title", "Details", pendingIntent);
        notificationManager.notify(0, notify);
4

2 に答える 2

1

使用することをお勧めします:

        Notification not = new Notification(idIcon, text, System.currentTimeMillis());
    PendingIntent pInt = PendingIntent.getActivity(ctx, 0, new Intent(ctx, the_class_to_call), 0);

    not.setLatestEventInfo(ctx, app_name, text, pInt);

そしてnot.notify...。

于 2012-08-31T10:59:38.403 に答える
0

AlertDialogを使用し、ポジティブボタンクリックで目的のアクティビティを起動します

于 2012-08-04T14:07:19.527 に答える