title: Getting null point exception when i declare latlong values globally
body: <p>I have got latlong values using shared preferences and stored it as double values.<br>
  Declared latlong values globally.<br>
  Getting null point Exception.
  Tried different ways of declaring values globally,but nothing seems working.</p>
  
  <p>MainActivity.java</p>
  
  <pre><code>public class MapsActivityConnect extends FragmentActivity {
  ImageView emerg;
  SharedPreferences pref;
  String vechile;
  Double deslatituded, deslongituded, srclatituded, srclongituded;
  private GoogleMap mMap = null;
  private final LatLng end = new LatLng(deslatituded, deslongituded);
  private final LatLng start = new LatLng(srclatituded, srclongituded);
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.activity_maps_activity_connect);
  
      pref = getSharedPreferences("gps", Context.MODE_PRIVATE);
  
      Bundle extras = getIntent().getExtras();
      if (extras != null) {
          deslatituded = extras.getDouble("deslatitude");
          deslongituded = extras.getDouble("deslongitude");
  
  
          srclatituded = extras.getDouble("srclatitude");
          srclongituded = extras.getDouble("srclongitude");
          vechile = extras.getString("vechile");
  
          if (!Utils.isConnected(getApplicationContext())) {
              Toast.makeText(getApplicationContext(), "Internet not available. Cross check your internet connectivity and try again", Toast.LENGTH_LONG).show();
              return;
          }
          if (!Utils.isGPSTurnOn(getApplicationContext())) {
              showGPSDialog();
              return;
          }
      }
  
  }
  
  @SuppressLint("NewApi")
  @Override
  protected void onResume() {
      super.onResume();
      if (Utils.isConnected(getApplicationContext())) {
          mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
          mMap.setMyLocationEnabled(true);
          final TextView txtDistance = (TextView) findViewById(R.id.txtSpeed);
          new Routing(getParent(), mMap, txtDistance).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, start, end);
      }
  }
  
  private void showGPSDialog() {
      new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AppBaseTheme)) // Theme
              .setTitle(R.string.gps_lable_gps) // setTitle
              .setMessage(R.string.gps_lable_warning_message) // setMessage
              .setInverseBackgroundForced(false).setCancelable(false) //
              .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(final DialogInterface dialog, final int which) {
                      startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);
                  }
              }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
          @Override
          public void onClick(final DialogInterface dialog, final int which) {
              dialog.dismiss();
          }
      }).setIcon(android.R.drawable.ic_dialog_alert).show();
  }
  
  @Override
  protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if (Utils.isGPSTurnOn(getApplicationContext())) {
          onResume();
      }
  }
  </code></pre>
  
  <p>}
          Logcat</p>
  
  <pre><code>9-29 13:40:56.383  32078-    32149/zybo.example.ramz.demo_location_tracking V/RenderScript﹕ Application   requested CPU execution
  09-29 13:40:56.393  32078-  32149/zybo.example.ramz.demo_location_tracking V/RenderScript﹕ 0xb7579cd8 Launching thread(s), CPUs 4
  09-29 13:41:01.527  32078-32078/zybo.example.ramz.demo_location_tracking D/AndroidRuntime﹕ Shutting down VM
  09-29 13:41:01.536  32078-32078/zybo.example.ramz.demo_location_tracking E/AndroidRuntime﹕ FATAL EXCEPTION: main
  Process: zybo.example.ramz.demo_location_tracking, PID: 32078
  java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{zybo.example.ramz.demo_location_tracking/zybo.example.ramz.demo_location_tracking.MapsActivityConnect}: java.lang.NullPointerException: Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2250)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)
          at android.app.ActivityThread.access$800(ActivityThread.java:155)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
          at android.os.Handler.dispatchMessage(Handler.java:102)
          at android.os.Looper.loop(Looper.java:135)
          at android.app.ActivityThread.main(ActivityThread.java:5343)
          at java.lang.reflect.Method.invoke(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:372)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
   Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference
          at zybo.example.ramz.demo_location_tracking.MapsActivityConnect.&lt;init&gt;(MapsActivityConnect.java:62)
          at java.lang.reflect.Constructor.newInstance(Native Method)
          at java.lang.Class.newInstance(Class.java:1606)
          at android.app.Instrumentation.newActivity(Instrumentation.java:1089)
          at   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2240)
    at     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)                                              
    at 
    android.app.ActivityThread.access$800(ActivityThread.java:155)
  </code></pre>