Have you set uses permission in manifiest file.

<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />

- Anurag Singh

Hi,
>
> I am trying to retrieve the GPS location of the phone. I believe I
> cannot create an object of the class which stores the location in a
> variable. So that once the class gets instantiated I use a get method
> and retrieve the content in the variable.
> So I am trying to do this....
>
> locationListener = new MyLocationListener();
>
>        lm.requestLocationUpdates(
>            LocationManager.GPS_PROVIDER,0,0,locationListener);
>        if(!information.equals(null)){
>                Bundle bundle = new Bundle();
>                bundle.putString("hello", information);
>                Intent intent = new Intent(LocationActivity.this,
> MainActivity.class);
>                intent.putExtras(bundle);
>                startActivity(intent);
>        }
>
>
> and in the locationlistener class
>
>
> public void onLocationChanged(Location loc) {
>            if (loc != null) {
>                double lat=loc.getLatitude();
>                double lon=loc.getLongitude();
>                information = " "+lat +lon;
>                Toast.makeText(getBaseContext(),
>                "Location Changed:"+information,
>                Toast.LENGTH_LONG).show();
>            }
>            else
>                information="bad luck";
>        }
>
> The mainactivity then displays that...but its not happening...could
> some one please help me how to get the values of this.
>
> Thanks...Raqeeb
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to