在android中显示通知

问题描述:

我正在使用下面的代码来显示我的android应用程序中的通知,但是使用这个,通知活动也显示出来(即黑色的空白屏幕)我不想要这个屏幕,但只是一个简单的通知,当用户点击通知时,我想启动该活动。该代码应该做什么?在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); 

我建议你使用:

 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 ....

使用AlertDialog,然后发动正面按钮您所需的活性单击