i keep getting this error on line but if i remove the null i get errors on context telling me to initialize variable..
nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
this is my code
public void createDialog(Enter_med enter_med) {
// TODO Auto-generated method stub
Context context = null;
NotificationManager nm;
nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence from = "VIPUL";
CharSequence message = "Crazy About Android...";
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
new Intent(), 0);
Notification notif = new Notification(R.drawable.ic_launcher,
"Crazy About Android...", System.currentTimeMillis());
notif.setLatestEventInfo(context, from, message, contentIntent);
nm.notify(1, notif);
}
You should try and initiate the
contextin youronCreate.And then you use it with
nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);Your problem is that you need to initiate it with the activity context, not
null