Android Application stop unexpectedly
<p>im doing an application which retrieve a location of a user using GPS and then redirect it to the new intent,let say if the user is in "Curve", it will redirect user to the Curve.class, but i got this error and it has been stopping me from proceeding.</p>

<pre><code>01-15 17:21:09.644: D/HttpRetriever(309): &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;&lt;ResultSet xmlns:ns1="http://www.yahooapis.com/v1/base.rng" version="2.0" xml:lang="en-US"&gt;&lt;Error&gt;0&lt;/Error&gt;&lt;ErrorMessage&gt;No error&lt;/ErrorMessage&gt;&lt;Locale&gt;en-US&lt;/Locale&gt;&lt;Found&gt;1&lt;/Found&gt;&lt;Quality&gt;99&lt;/Quality&gt;&lt;Result&gt;&lt;quality&gt;72&lt;/quality&gt;&lt;latitude&gt;3.158695&lt;/latitude&gt;&lt;longitude&gt;101.611586&lt;/longitude&gt;&lt;offsetlat&gt;3.158695&lt;/offsetlat&gt;&lt;offsetlon&gt;101.611586&lt;/offsetlon&gt;&lt;radius&gt;400&lt;/radius&gt;&lt;name&gt;3.1580999999999997, 101.61209833333332&lt;/name&gt;&lt;line1&gt;Jalan Pju 7/3&lt;/line1&gt;&lt;line2&gt;47800 Bandar Utama&lt;/line2&gt;&lt;line3&gt;&lt;/line3&gt;&lt;line4&gt;Malaysia&lt;/line4&gt;&lt;house&gt;&lt;/house&gt;&lt;street&gt;Jalan Pju 7/3&lt;/street&gt;&lt;xstreet&gt;&lt;/xstreet&gt;&lt;unittype&gt;&lt;/unittype&gt;&lt;unit&gt;&lt;/unit&gt;&lt;postal&gt;47800&lt;/postal&gt;&lt;neighborhood&gt;Bandar Utama&lt;/neighborhood&gt;&lt;city&gt;Sungai Buloh&lt;/city&gt;&lt;county&gt;Petaling&lt;/county&gt;&lt;state&gt;Selangor&lt;/state&gt;&lt;country&gt;Malaysia&lt;/country&gt;&lt;countrycode&gt;MY&lt;/countrycode&gt;&lt;statecode&gt;&lt;/statecode&gt;&lt;countycode&gt;&lt;/countycode&gt;&lt;uzip&gt;47800&lt;/uzip&gt;&lt;hash&gt;&lt;/hash&gt;&lt;woeid&gt;28347311&lt;/woeid&gt;&lt;woetype&gt;11&lt;/woetype&gt;&lt;/Result&gt;&lt;/ResultSet&gt;
01-15 17:21:09.644: D/HttpRetriever(309): &lt;!-- nws01.maps.bf1.yahoo.com uncompressed/chunked Tue Jan 15 09:21:01 PST 2013 --&gt;
01-15 17:21:09.644: D/HttpRetriever(309): &lt;!-- wws07.geotech.ne1.yahoo.com uncompressed/chunked Tue Jan 15 09:21:00 PST 2013 --&gt;
01-15 17:21:09.733: D/dalvikvm(309): GC_FOR_MALLOC freed 2299 objects / 157648 bytes in 58ms
01-15 17:21:09.754: D/XmlParser(309): Location:-Jalan Pju 7/3-47800 Bandar Utama-Malaysia
01-15 17:21:10.134: D/AndroidRuntime(309): Shutting down VM
01-15 17:21:10.134: W/dalvikvm(309): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
01-15 17:21:10.157: E/AndroidRuntime(309): FATAL EXCEPTION: main
01-15 17:21:10.157: E/AndroidRuntime(309): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.javacodegeeks.android.lbs/com.javacodegeeks.android.lbs.Curve}: java.lang.NullPointerException
01-15 17:21:10.157: E/AndroidRuntime(309):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
01-15 17:21:10.157: E/AndroidRuntime(309):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-15 17:21:10.157: E/AndroidRuntime(309):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-15 17:21:10.157: E/AndroidRuntime(309):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-15 17:21:10.157: E/AndroidRuntime(309):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-15 17:21:10.157: E/AndroidRuntime(309):  at android.os.Looper.loop(Looper.java:123)
01-15 17:21:10.157: E/AndroidRuntime(309):  at android.app.ActivityThread.main(ActivityThread.java:4627)
01-15 17:21:10.157: E/AndroidRuntime(309):  at java.lang.reflect.Method.invokeNative(Native Method)
01-15 17:21:10.157: E/AndroidRuntime(309):  at java.lang.reflect.Method.invoke(Method.java:521)
01-15 17:21:10.157: E/AndroidRuntime(309):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-15 17:21:10.157: E/AndroidRuntime(309):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-15 17:21:10.157: E/AndroidRuntime(309):  at dalvik.system.NativeStart.main(Native Method)
01-15 17:21:10.157: E/AndroidRuntime(309): Caused by: java.lang.NullPointerException
01-15 17:21:10.157: E/AndroidRuntime(309):  at com.javacodegeeks.android.lbs.Curve.onCreate(Curve.java:59)
01-15 17:21:10.157: E/AndroidRuntime(309):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-15 17:21:10.157: E/AndroidRuntime(309):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
01-15 17:21:10.157: E/AndroidRuntime(309):  ... 11 more
01-15 17:21:11.204: D/All Products:(309): {"success":1,"daftar_promotion":[{"id":"26","PromoImage":"\/images\/ego1.jpg","PromoCate":"Health  ","PromoDesc":"5% discount for items above RM200","PromoDateStart":"1-1-2013","Contact":"","PromoDateEnd":"31-1-2013","PromoName":"Egonutritions 5%  "},{"id":"27","PromoImage":"\/images\/dna.png","PromoCate":"Fashion","PromoDesc":"20% off for all shoes","PromoDateStart":"1-1-2013","Contact":"","PromoDateEnd":"31-1-2013","PromoName":"DNA New Year Sales"}]}
01-15 17:21:11.204: W/System.err(309): org.json.JSONException: No value for PromoID
01-15 17:21:11.404: W/System.err(309):  at org.json.JSONObject.get(JSONObject.java:354)
01-15 17:21:11.484: W/System.err(309):  at org.json.JSONObject.getString(JSONObject.java:510)
01-15 17:21:11.484: W/System.err(309):  at com.javacodegeeks.android.lbs.Curve$Activity.doInBackground(Curve.java:105)
01-15 17:21:11.484: W/System.err(309):  at com.javacodegeeks.android.lbs.Curve$Activity.doInBackground(Curve.java:1)
01-15 17:21:11.484: W/System.err(309):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
01-15 17:21:11.484: W/System.err(309):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
01-15 17:21:11.484: W/System.err(309):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
01-15 17:21:11.484: W/System.err(309):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
01-15 17:21:11.484: W/System.err(309):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
01-15 17:21:11.534: W/System.err(309):  at java.lang.Thread.run(Thread.java:1096)
</code></pre>

<p>and this is my Curve.java</p>

<pre><code>package com.javacodegeeks.android.lbs;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.widget.Toast;
import lbs.promotion.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.http.NameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class Curve extends Activity {

    private ProgressDialog pDialog;
     JSONParser jParser = new JSONParser();
     ArrayList&lt;HashMap&lt;String, String&gt;&gt; DaftarPromotion = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();

     private static String url_daftar_promotion = "http://10.0.2.2/webserver_maaug/promotion/daftar_promotion.php";

     public static final String TAG_SUCCESS = "success";
     public static final String TAG_DAFTAR_PROMOTION = "daftar_promotion";
     public static final String TAG_ID_PROMO = "PromoID";
     public static final String TAG_NAMA_PROMO = "PromoName";
     public static final String TAG_LINK_IMAGE_PROMO = "PromoImage";
     public static final String TAG_DESC_PROMO= "PromoDesc";
     public static final String TAG_CATE_PROMO = "PromoCate";

     JSONArray daftar_promotion = null;

     ListView list;
     PromotionListAdapter adapter;

     private Curve activity;

     @Override
     public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.main);
     DaftarPromotion = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();

      new Activity().execute();
      activity = this;
      list = (ListView) findViewById(R.id.list);
      list.setOnItemClickListener(new OnItemClickListener() {
      @Override
      public void onItemClick(AdapterView&lt;?&gt; parent, View view,
      int position, long id) {
      }
      });
      }

      public void SetListViewAdapter(ArrayList&lt;HashMap&lt;String, String&gt;&gt; daftar) {
      adapter = new PromotionListAdapter(activity, daftar);
      list.setAdapter(adapter);
      }

      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if (resultCode == 100) {
      Intent intent = getIntent();
      finish();
      startActivity(intent);
      }
      }

      class Activity extends AsyncTask&lt;String, String, String&gt; {

      @Override
      protected void onPreExecute() {
      super.onPreExecute();
      pDialog = new ProgressDialog(Curve.this);
      pDialog.setMessage("Please Wait...");
      pDialog.setIndeterminate(false);
      pDialog.setCancelable(false);
      pDialog.show();
      }

      protected String doInBackground(String... args) {
      List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
      JSONObject json = jParser.makeHttpRequest(url_daftar_promotion, "GET",params);

      Log.d("All Products: ", json.toString());
      try {
      int success = json.getInt(TAG_SUCCESS);
      if (success == 1) {
           daftar_promotion = json.getJSONArray(TAG_DAFTAR_PROMOTION);
           for (int i = 0; i &lt; daftar_promotion.length();i++){
           JSONObject c = daftar_promotion.getJSONObject(i);
           String PromoID = c.getString(TAG_ID_PROMO);
           String PromoName = c.getString(TAG_NAMA_PROMO);
           String PromoImage = c.getString(TAG_LINK_IMAGE_PROMO);
           String PromoDesc = c.getString(TAG_DESC_PROMO);
           String PromoCate = c.getString(TAG_CATE_PROMO);

           HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();

           map.put(TAG_ID_PROMO, PromoID);
           map.put(TAG_NAMA_PROMO, PromoName);
           map.put(TAG_LINK_IMAGE_PROMO, PromoImage);
           map.put(TAG_DESC_PROMO, PromoDesc);
           map.put(TAG_CATE_PROMO, PromoCate);

           DaftarPromotion.add(map);
           }

           } else {
           }
           } catch (JSONException e) {
           e.printStackTrace();
           }
           return null;
           }

           protected void onPostExecute(String file_url) {
           pDialog.dismiss();
           runOnUiThread(new Runnable() {
           public void run() {

           SetListViewAdapter(DaftarPromotion);
                }
           });
        }
    }
    }
</code></pre>

<p>and this is the main activity which will redirect user to the curve intent</p>

<pre><code>package com.javacodegeeks.android.lbs;


import java.text.DecimalFormat;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

import com.javacodegeeks.android.lbs.model.GeoCodeResult;
import com.javacodegeeks.android.lbs.services.GeoCoder;

public class LbsGeocodingActivity extends Activity {

    private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1; // in Meters
    private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000; // in Milliseconds

    private GeoCoder geoCoder = new GeoCoder();


    double longi = 0.0;
    double lati = 0.0;

    String lon = "";
    String lat = "";

    protected LocationManager locationManager;
    protected Location currentLocation;

    protected Button retrieveLocationButton;
    protected Button reverseGeocodingButton;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        retrieveLocationButton = (Button) findViewById(R.id.retrieve_location_button);
        reverseGeocodingButton = (Button) findViewById(R.id.reverse_geocoding_button);

        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

        locationManager.requestLocationUpdates(
                LocationManager.GPS_PROVIDER, 
                MINIMUM_TIME_BETWEEN_UPDATES, 
                MINIMUM_DISTANCE_CHANGE_FOR_UPDATES,
                new MyLocationListener()
        );

        retrieveLocationButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                getLocation();
            }
        });

        reverseGeocodingButton.setOnClickListener(new OnClickListener() {           
            @Override
            public void onClick(View v) {               
                performReverseGeocodingInBackground();
            }
        });

    }    

    protected void performReverseGeocodingInBackground() {
        getLocation();
        new ReverseGeocodeLookupTask().execute((Void[])null);
    }

    protected void getLocation() {

        currentLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);




    //  if (currentLocation != null) {
//          String message = String.format(
//  "ori"               "Current Location \n Longitude: %1$s \n Latitude: %2$s",
//                  currentLocation.getLongitude(), currentLocation.getLatitude()
//          );
//          Toast.makeText(LbsGeocodingActivity.this, message,
//                  Toast.LENGTH_LONG).show();
    //  }

    }   

    private class MyLocationListener implements LocationListener {

        public void onLocationChanged(Location location) {
            String message = String.format(
                    "New Location \n Longitude: %1$s \n Latitude: %2$s",
                    location.getLongitude(), location.getLatitude()
            );
        //  Toast.makeText(LbsGeocodingActivity.this, message, Toast.LENGTH_LONG).show();
        }

        public void onStatusChanged(String s, int i, Bundle b) {
        //  Toast.makeText(LbsGeocodingActivity.this, "Provider status changed",
                    //Toast.LENGTH_LONG).show();
        }

        public void onProviderDisabled(String s) {
        //  Toast.makeText(LbsGeocodingActivity.this,
        //          "Provider disabled by the user. GPS turned off",
            //      Toast.LENGTH_LONG).show();
        }

        public void onProviderEnabled(String s) {
            //Toast.makeText(LbsGeocodingActivity.this,
            //      "Provider enabled by the user. GPS turned on",
            //      Toast.LENGTH_LONG).show();
        }

    }


    public class ReverseGeocodeLookupTask extends AsyncTask &lt;Void, Void, GeoCodeResult&gt; {

        private ProgressDialog progressDialog;

        @Override
        protected void onPreExecute() {
            this.progressDialog = ProgressDialog.show(
                    LbsGeocodingActivity.this,
                    "Please wait", // title
                    "Acquiring Location", // message
                    true // indeterminate
            );
        }

        @Override
        protected GeoCodeResult doInBackground(Void... params) {
            return geoCoder.reverseGeoCode(currentLocation.getLatitude(), currentLocation.getLongitude());
        }

        @Override
        protected void onPostExecute(GeoCodeResult result) {
            this.progressDialog.cancel();
            //Toast.makeText(LbsGeocodingActivity.this, result.toString(), Toast.LENGTH_LONG).show();   

            DecimalFormat format = new DecimalFormat();             
            format.setMaximumFractionDigits(4);

             longi = currentLocation.getLongitude();
             lati = currentLocation.getLatitude();

            String lon = format.format(longi);
            String lat = format.format(lati);



            if((lon.equalsIgnoreCase("101.6121")) &amp;&amp; (lat.equalsIgnoreCase("3.1581"))   ){
            //Toast.makeText(LbsGeocodingActivity.this, "The curve", Toast.LENGTH_LONG).show();

                 Intent intent = new Intent(LbsGeocodingActivity.this, Curve.class);
                 intent.putExtra("lon",lon);
                 intent.putExtra("lat",lat);
                 startActivity(intent);


            }
            else if((lon.equalsIgnoreCase("101.5178")) &amp;&amp; (lat.equalsIgnoreCase("3.0724"))   ){
                //Toast.makeText(LbsGeocodingActivity.this, "Sacc", Toast.LENGTH_LONG).show();

                 Intent intent = new Intent(LbsGeocodingActivity.this, Sacc.class);
                 intent.putExtra("lon",lon);
                 intent.putExtra("lat",lat);
                 startActivity(intent);

                }
            else if((lon.equalsIgnoreCase("101.6356")) &amp;&amp; (lat.equalsIgnoreCase("3.1175"))   ){
                //Toast.makeText(LbsGeocodingActivity.this, "Jaya One", Toast.LENGTH_LONG).show();

                 Intent intent = new Intent(LbsGeocodingActivity.this, Jaya.class);
                 intent.putExtra("lon",lon);
                 intent.putExtra("lat",lat);
                 startActivity(intent);

                }

            }

    }

}
</code></pre>
