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 回答