GPS not working in Async Task
I have implemented a simple GPS program that fetches the co-ordinates and displays them on the screen. When I tried to improve on this design and implement an async task, the GPS doesn't seem to work for some reason or another. Is there some issue with regards to using async task with GPS? Here is my code:

    private class DownloadTask extends AsyncTask<String, Void, Object> {
    		protected Object doInBackground(String... args) {
    			Log.i("MyApp", "Background thread starting");
			
		        LocationManager mLocationManager;
		        Gpslistener Gpslistener;

		        Gpslistener = new Gpslistener();
		        	
		        try{
		        	
		           mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

		           mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,Gpslistener);
		           
		        }catch (Exception e) {

		        	test_gps = true;
		       }


			return null;
		}

		protected void onPostExecute(Object result) {

			if(test_gps == true){
				if (ParkingActivity.this.progressDialog != null) {
					ParkingActivity.this.progressDialog.dismiss();
				}				
				AlertMessage("GPS Error", "Unable to get location");
			}



    public class Gpslistener implements LocationListener
	{
			@Override
			public void onLocationChanged(Location loc)
			{
				loc.getLatitude();
				loc.getLongitude();
			}

			@Override
			public void onProviderDisabled(String provider)
			{		
			}

			@Override
			public void onProviderEnabled(String provider)
			{
			}

			@Override
			public void onStatusChanged(String provider, int status, Bundle extras)
			{
			}
		}

Each time I run it, it always catches an exception. The GPS permissions are set in the manifest and I'm always using a different application to ensure that a GPS connection is online so I eliminated those as potential errors. Honestly I can't think of anything else, without the async task it works perfectly! Any help is much appreciated, thanks!
GPS not working in Async Task
===

I have implemented a simple GPS program that fetches the co-ordinates and displays them on the screen. When I tried to improve on this design and implement an async task, the GPS doesn't seem to work for some reason or another. Is there some issue with regards to using async task with GPS? Here is my code:

    private class DownloadTask extends AsyncTask<String, Void, Object> {
    		protected Object doInBackground(String... args) {
    			Log.i("MyApp", "Background thread starting");
			
		        LocationManager mLocationManager;
		        Gpslistener Gpslistener;

		        Gpslistener = new Gpslistener();
		        	
		        try{
		        	
		           mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

		           mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,Gpslistener);
		           
		        }catch (Exception e) {

		        	test_gps = true;
		       }


			return null;
		}

		protected void onPostExecute(Object result) {

			if(test_gps == true){
				if (ParkingActivity.this.progressDialog != null) {
					ParkingActivity.this.progressDialog.dismiss();
				}				
				AlertMessage("GPS Error", "Unable to get location");
			}



    public class Gpslistener implements LocationListener
	{
			@Override
			public void onLocationChanged(Location loc)
			{
				loc.getLatitude();
				loc.getLongitude();
			}

			@Override
			public void onProviderDisabled(String provider)
			{		
			}

			@Override
			public void onProviderEnabled(String provider)
			{
			}

			@Override
			public void onStatusChanged(String provider, int status, Bundle extras)
			{
			}
		}

Each time I run it, it always catches an exception. The GPS permissions are set in the manifest and I'm always using a different application to ensure that a GPS connection is online so I eliminated those as potential errors. Honestly I can't think of anything else, without the async task it works perfectly! Any help is much appreciated, thanks!