2013-05-27 4 views
7

मुझे एक अधिसूचना बनाने की आवश्यकता है, जो शीर्ष पर प्रदर्शित होगा लेकिन इसे किसी भी पृष्ठ पर नेविगेट नहीं करना चाहिए, किसी भी ऑनक्लिक फ़ंक्शन नहीं होना चाहिए।लंबित इरादे के बिना अधिसूचना

यहां कोड है जिसका मैंने उपयोग किया है।

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); 

किसी को भी मेरी मदद कर सके। @ धन्यवाद

उत्तर

18

उपयोग Intent wihtout, घटक होने की तरह

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

यह एक तरह से जहां उपयोग एक Activity नहीं खोल सकता प्रदान करना है।

+0

धन्यवाद मुझे –

+1

आज़माएं यह आईसीएस पर काम है? @ पंकज कुमार !! –

+0

@ZalaJanaksinh हां। –

संबंधित मुद्दे