I use a GPSTracker class, with the method OnLocationChanged I want to send a notification when ....the locaiton change :)
i use :
@Override
public void onLocationChanged(Location location) {
latitude = (double) (location.getLatitude());
longitude = (double) (location.getLongitude());
// Toast.makeText(this, "fffff", Toast.LENGTH_LONG).show();
// Toast.makeText(getApplicationContext(), Double.toString(latitude) , Toast.LENGTH_LONG).show();
Log.i("okok", "position changee" + Double.toString(latitude) + "-" + Double.toString(longitude));
NotificationManager notif = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notify = new Notification(R.drawable.a, "tittle", System.currentTimeMillis());
PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0);
notify.setLatestEventInfo(getApplicationContext(), "subject", "body", pending);
notif.notify(0, notify);
}
and there is an error on the 1st line of the NotificationLManager: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
Same issue when trying to use an HttpConnection to a remote website. I tryied already to use the try{} method
Would you have an idea pleaaaaase thanks David