title: The program is showing null pointer exception....converting double to int
body: <p>My program causes a null pointer exception... I think the problem is in converting lat3 and lon3 from double to int... Is there some other way of parsing the location in double to int to give it to GeoPoint?</p>
  
  <p>Code:</p>
  
  <pre><code>public class mapLoc extends com.google.android.maps.MapActivity implements LocationListener
  {
      TextView t ;
      int lat2,lon2,lat3,lon3;
      Double presentlon,presentlat;
  
      Drawable d;
      MapView mv;
      MapController mc;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) 
      {
  
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.map);
  
          t = (TextView)findViewById(R.id.maptxt);
  
          Intent intent = getIntent();
          Bundle extra = intent.getExtras();
  
       String latitude = extra.getString("latitude");
       String longitude = extra.getString("longitude");
  
       t.append(latitude+"\t");
       t.append(longitude);
       Float lat1 = Float.parseFloat(latitude);
       Float lon1 = Float.parseFloat(longitude);
          lat2 = (int) (lat1*1E6);   
          lon2 = (int) (lon1*1E6); 
  
  
          mv = (MapView)findViewById(R.id.maps);
  
          mc = mv.getController();
          mc.setZoom(14);
          mv.setBuiltInZoomControls(true);
          mv.displayZoomControls(true);
          mv.setClickable(true);
  
  
       List&lt;Overlay&gt; mapOverlays = mv.getOverlays();
       Drawable drawable = this.getResources().getDrawable(R.drawable.marker);
       overlay itemizedoverlay = new overlay(drawable, this);
  
       lat3 = (int)(presentlat * 1E6);
       lon3 = (int)(presentlon * 1E6);
  
  
       GeoPoint point = new GeoPoint(lat3, lon3);
  
       OverlayItem overlayitem = new OverlayItem(point, "Hello, user", "This is your present location");
       mc.animateTo(point);
  
       itemizedoverlay.addOverlay(overlayitem);
       mapOverlays.add(itemizedoverlay);
  
       GeoPoint point2 = new GeoPoint(lat2, lon2);
       OverlayItem overlayitem2 = new OverlayItem(point2, "This is your","saved location");
       itemizedoverlay.addOverlay(overlayitem2);
       mapOverlays.add(itemizedoverlay);
  
  
  
      }
  
  
      @Override
      public void onLocationChanged(Location location)
      {
       presentlat = location.getLatitude();
       presentlon =  location.getLongitude();
  
      }
  
      @Override
      public void onProviderDisabled(String provider) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void onProviderEnabled(String provider) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void onStatusChanged(String provider, int status, Bundle extras) {
          // TODO Auto-generated method stub
  
      }
  
  
      @Override
      protected boolean isRouteDisplayed() {
          // TODO Auto-generated method stub
          return false;
      };
  
  
  
  }
  </code></pre>
  
  <p>Logcat errors:</p>
  
  <pre><code>05-25 10:21:52.444: W/dalvikvm(342): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
  05-25 10:21:52.444: E/AndroidRuntime(342): Uncaught handler: thread main exiting due to uncaught exception
  05-25 10:21:52.454: E/AndroidRuntime(342): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.loc/com.loc.mapLoc}: java.lang.NullPointerException
  05-25 10:21:52.454: E/AndroidRuntime(342):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
  05-25 10:21:52.454: E/AndroidRuntime(342):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
  05-25 10:21:52.454: E/AndroidRuntime(342):  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
  05-25 10:21:52.454: E/AndroidRuntime(342):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
  05-25 10:21:52.454: E/AndroidRuntime(342):  at android.os.Handler.dispatchMessage(Handler.java:99)
  05-25 10:21:52.454: E/AndroidRuntime(342):  at android.os.Looper.loop(Looper.java:123)
  05-25 10:21:52.454: E/AndroidRuntime(342):  at android.app.ActivityThread.main(ActivityThread.java:4363)
  05-25 10:21:52.454: E/AndroidRuntime(342):  at java.lang.reflect.Method.invokeNative(Native Method)
  05-25 10:21:52.454: E/AndroidRuntime(342):  at java.lang.reflect.Method.invoke(Method.java:521)
  05-25 10:21:52.454: E/AndroidRuntime(342):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
  05-25 10:21:52.454: E/AndroidRuntime(342):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  05-25 10:21:52.454: E/AndroidRuntime(342):  at dalvik.system.NativeStart.main(Native Method)
  05-25 10:21:52.454: E/AndroidRuntime(342): Caused by: java.lang.NullPointerException
  05-25 10:21:52.454: E/AndroidRuntime(342):  at com.loc.mapLoc.onCreate(mapLoc.java:71)
  05-25 10:21:52.454: E/AndroidRuntime(342):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  05-25 10:21:52.454: E/AndroidRuntime(342):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
  </code></pre>