2013-05-27 35 views
7

Tôi cần tạo thông báo, sẽ hiển thị ở trên cùng nhưng không được điều hướng đến bất kỳ trang nào, không được có bất kỳ chức năng onclick nào.thông báo không có mục đích đang chờ xử lý

đây là mã mà tôi đã sử dụng.

notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
myNotification = new Notification(R.drawable.icon,"Notification!", System.currentTimeMillis()); 

Context context = getApplicationContext(); 

String notificationTitle = "Message"; 
String notificationText = Msg; 
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(myBlog), context, com.gurupro.LiveChat.class); 

myIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_CLEAR_TOP); 




//PendingIntent pendingIntent = PendingIntent.getActivity(Home.this, 0, myIntent, 0); 



myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); 

//myIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); 
myNotification.defaults |= Notification.DEFAULT_SOUND; 
myNotification.flags |= Notification.FLAG_AUTO_CANCEL; 



myNotification.setLatestEventInfo(context, notificationTitle,notificationText, pendingIntent); 
notificationManager.notify(MY_NOTIFICATION_ID, myNotification); 

Ai có thể giúp tôi. @ Nhờ

Trả lời

18

Sử dụng Intent wihtout có thành phần, như dưới đây

PendingIntent contentIntent = PendingIntent.getActivity(
    getApplicationContext(), 
    0, 
    new Intent(), // add this 
    PendingIntent.FLAG_UPDATE_CURRENT); 

Đây là cung cấp một cách nơi sử dụng không thể mở một Activity.

+0

cảm ơn hãy để tôi thử –

+1

Nó hoạt động trên ICS? @Pankaj Kumar !! –

+0

@ZalaJanaksinh Có. –

Các vấn đề liên quan