मेरी सूचना एक सेवा (service.java) और क्या सेवा कर बैटरी स्तर की एक अधिसूचना शुरू जब वरीयता स्क्रीन में एक checkboxpreference चेक किया गया है .. क्या अब नहीं काम करता है आशय है अधिसूचना पर क्लिक करने के लिए MainActivity
में प्रवेश करने के लिए। यह कोडअधिसूचना में आशय से काम नहीं करता
if(mprefs.getBoolean("notification_a", false)==true){
notificationBuilder = new NotificationCompat.Builder(context);
notificationBuilder.setOngoing(true);
notificationBuilder.setContentTitle("Battery Stats Informations");
notificationBuilder.setContentText("Carica residua: " +level+"%" + " " + "Temperatura: " +temperature+ "°C");
//notificationBuilder.setTicker("Informazioni batteria");
notificationBuilder.setWhen(System.currentTimeMillis());
notificationBuilder.setSmallIcon(R.drawable.icon_small_not);
Intent notificationIntent = new Intent(context, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getBroadcast(context, 0, notificationIntent, 0);
notificationBuilder.setContentIntent(contentIntent);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
Notification not=notificationBuilder.build();
mNotificationManager.notify(SIMPLE_NOTIFICATION_ID,not);
} else {
mNotificationManager.cancelAll();
}
इरादा Intent notificationIntent = new Intent(context, MainActivity.class
कार्य नहीं करता है। कोई मदद करता है?
ठीक है, तो मैं कोशिश करूँगा .. लेकिन जो 'getActivity' और' getBroadcast' के बीच अलग है? –