GPS app crashing
<p>What I am doing is trying to get a basic GPS working and the logcat says: 03-04 17:06:37.052: E/AndroidRuntime(278): FATAL EXCEPTION: main
03-04 17:06:37.052: E/AndroidRuntime(278): java.lang.RuntimeException: Unable to start activity ComponentInfo{Weather.app/Weather.app.WeatherAppActivity}: java.lang.IllegalArgumentException: listener==null
03-04 17:06:37.052: E/AndroidRuntime(278):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-04 17:06:37.052: E/AndroidRuntime(278):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-04 17:06:37.052: E/AndroidRuntime(278):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-04 17:06:37.052: E/AndroidRuntime(278):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-04 17:06:37.052: E/AndroidRuntime(278):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-04 17:06:37.052: E/AndroidRuntime(278):  at android.os.Looper.loop(Looper.java:123)
03-04 17:06:37.052: E/AndroidRuntime(278):  at android.app.ActivityThread.main(ActivityThread.java:4627)
03-04 17:06:37.052: E/AndroidRuntime(278):  at java.lang.reflect.Method.invokeNative(Native Method)
03-04 17:06:37.052: E/AndroidRuntime(278):  at java.lang.reflect.Method.invoke(Method.java:521)
03-04 17:06:37.052: E/AndroidRuntime(278):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-04 17:06:37.052: E/AndroidRuntime(278):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-04 17:06:37.052: E/AndroidRuntime(278):  at dalvik.system.NativeStart.main(Native Method)
03-04 17:06:37.052: E/AndroidRuntime(278): Caused by: java.lang.IllegalArgumentException: listener==null
03-04 17:06:37.052: E/AndroidRuntime(278):  at android.location.LocationManager.requestLocationUpdates(LocationManager.java:628)
03-04 17:06:37.052: E/AndroidRuntime(278):  at Weather.app.WeatherAppActivity.onCreate(WeatherAppActivity.java:36)
03-04 17:06:37.052: E/AndroidRuntime(278):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-04 17:06:37.052: E/AndroidRuntime(278):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-04 17:06:37.052: E/AndroidRuntime(278):  ... 11 more</p>

<pre><code>public class WeatherAppActivity extends Activity{
/** Called when the activity is first created. */
 //private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1; // in Meters
 //private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000; // in Milliseconds
static final String tag = "Main"; // for Log

protected LocationManager locationManager;
protected LocationListener MyLocationListener;
protected Button findButton;

    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout ll = new LinearLayout(this);
    findButton = new Button(this);
    ll.addView(findButton);
    setContentView(ll);
    locationListener  = new MyLocationListener();
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(
            LocationManager.GPS_PROVIDER, 0, 0, locationListener
            );



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

    protected void showCurrentLocation() {

                Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

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

                }

                final class MyLocationListener implements LocationListener {
                     @Override
                        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(WeatherAppActivity.this, message, Toast.LENGTH_LONG).show();
                        }
                     @Override
                        public void onStatusChanged(String provider, int status, Bundle extras) {
                            /* This is called when the GPS status alters */
                            switch (status) {
                            case LocationProvider.OUT_OF_SERVICE:
                                Log.v(tag, "Status Changed: Out of Service");
                                Toast.makeText(WeatherAppActivity.this, "Status Changed: Out of Service",
                                        Toast.LENGTH_SHORT).show();
                                break;
                            case LocationProvider.TEMPORARILY_UNAVAILABLE:
                                Log.v(tag, "Status Changed: Temporarily Unavailable");
                                Toast.makeText(WeatherAppActivity.this, "Status Changed: Temporarily Unavailable",
                                        Toast.LENGTH_SHORT).show();
                                break;
                            case LocationProvider.AVAILABLE:
                                Log.v(tag, "Status Changed: Available");
                                Toast.makeText(WeatherAppActivity.this, "Status Changed: Available",
                                        Toast.LENGTH_SHORT).show();
                                break;
                            }
                        }
                     @Override
                        public void onProviderDisabled(String provider) {
                            Toast.makeText(WeatherAppActivity.this,
                                  "Provider disabled by the user. GPS turned off",
                                      Toast.LENGTH_LONG).show();
                            }
                     @Override
                        public void onProviderEnabled(String provider) {
                            Toast.makeText(WeatherAppActivity.this,
                                   "Provider enabled by the user. GPS turned on",
                                       Toast.LENGTH_LONG).show();
                          }


                }                           






}
}
</code></pre>

<p>This is also in my manifest:</p>

<pre><code>    &lt;uses-permission android:name="android.permission.INTERNET"&gt;&lt;/uses-permission&gt;
    &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
&lt;uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /&gt;
&lt;uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" /&gt;
</code></pre>
