मैं अपने अनुप्रयोग के लिए सेटअप एक सूचना मिली है और कोड इस प्रकार है:अधिसूचना बटन काम नहीं कर रहा क्लिक
public int getNotification(View view) {
NotificationManager notificationManager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(getActivity() ,RouteMap.class);
intent.putExtra("Stop Ride",true);
PendingIntent pendingIntent = PendingIntent.getActivity(getActivity(), (int) System.currentTimeMillis(), intent, 0) ;
if (Build.VERSION.SDK_INT < 16) {
getToast("API below 16 ...notification not supported");
} else {
Notification notify = new Notification.Builder(getActivity())
.setSmallIcon(R.drawable.icon1)
.setContentTitle("Car Rental")
.setContentText("Click to view ")
.setOngoing(true)
.setContentIntent(pendingIntent)
.addAction(R.drawable.icon3,"View ",pendingIntent)
.addAction(R.drawable.alert_icon,"Stop Ride", pendingIntent)
.build();
notificationManager.notify(notificationID, notify);
}
return notificationID;
}
public void removeNotification() {
NotificationManager manager = (NotificationManager)getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
manager.cancel(
notificationID);
getToast("Notification Removed");
}
एप्लिकेशन अधिसूचना दिखाने लेकिन किसी भी क्रिया को निष्पादित नहीं करता है जब अधिसूचना पर बटन क्लिक किया कृपया मदद अगर मेरे कोड में कुछ जोड़ा जाना है तो मुझे।
अद्यतन: नीचे सुझाव के रूप में के रूप में इस पद्धति का एक टुकड़ा वर्ग
मैं अपने कोड के कुछ बदल गया है के अंदर है, लेकिन यह काम नहीं किया:
public int getNotification(View view) {
// NotificationManager notificationManager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent = new Intent(getActivity(), RouteMap.class);
PendingIntent pendingIntent = PendingIntent.getActivity(getActivity(), 0, intent, 0);
NotificationManager notificationManager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
if (Build.VERSION.SDK_INT < 16) {
getToast("API below 16 ...notification not supported");
} else {
Notification notify = new Notification.Builder(getActivity())
.setSmallIcon(R.drawable.icon12)
.setContentTitle("Car Rental")
.setContentText("Click to view ")
.setOngoing(true)
.setSound(soundUri)
.setContentIntent(pendingIntent)
.addAction(R.drawable.icon3, "View ", pendingIntent)
.addAction(R.drawable.alert_icon, "Stop Ride", pendingIntent)
.build();
notificationManager.notify(notificationID, notify);
}
return notificationID;
}
अग्रिम धन्यवाद ..
आप देखना चाहें [इस] (http://stackoverflow.com/questions/11270898/how-to-execute-a-method-by-clicking-a-notification) बाहर। – zionpi