OK one change Toast.makeText requires show() method to show toast. I
added it and still onLocationChange not called.

On Aug 28, 1:32 pm, Bipin Sutariya <[email protected]> wrote:
> Hi,
>
> I am trying to develop application in which i need current lat/lang.
> However onLocationChange method never get called.
>
> Following is my code, and note that i have given all required
> permission like android.permission.ACCESS_COARSE_LOCATION,
> android.permission.ACCESS_FINE_LOCATION, android.permission.INTERNET
> in manifest file. I can see gps icon on status bar that keep blinking
> to find location, but never get success.
>
> Can any one please help me on this.
>
> public class LocationServiceActivity extends Activity implements
> LocationListener{
>     /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.main);
>
>         LocationManager lm =
> (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
>
>         Boolean isGPSEnabled =
> lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
>         Boolean isNetworkEnabled =
> lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
>
>         if(isGPSEnabled)
>         {
>                 lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
> this);
>         }
>         else if(isNetworkEnabled)
>         {
>                 lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
> 0, 0, this);
>         }
>         else
>         {
>                 Toast.makeText(this, "NO SERVICE ENABLED", 5000);
>         }
>
>     }
>
>     public void onLocationChanged(Location location) {
>         Toast.makeText(this, location.getLatitude()+"---
>
> >"+location.getLongitude(), 5000);
>
>     }
>     public void onProviderDisabled(String provider) {
>         // TODO Auto-generated method stub
>
>     }
>     public void onProviderEnabled(String provider) {
>         // TODO Auto-generated method stub
>
>     }
>     public void onStatusChanged(String provider, int status, Bundle
> extras) {
>         // TODO Auto-generated method stub
>
>     }
>
>
>
>
>
>
>
> }

-- 
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