yeah. thanks alot i working fine. but now i have a new problem, it
completely diferent with this map think.
please fisit my new topic
https://groups.google.com/forum/?hl=en&fromgroups#!topic/android-developers/QKoyL6UQMk0
.
Thanks
On Saturday, May 26, 2012 3:47:12 PM UTC+7, Alfa wrote:
>
> hi, i want to get my location in longitude and latitude from gps, and
> i use this code
>
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.googlemapview);
> mv = (MapView)findViewById(R.id.mapview);
> LocationManager mlocManager =
> (LocationManager)getSystemService(Context.LOCATION_SERVICE);
> //MyLocationListener myLocListener = new
> MyLocationListener();
> //LocationListener mlocListener = locationListener;
>
>
> boolean isGPS = mlocManager
> .isProviderEnabled(LocationManager.GPS_PROVIDER);
>
> // If GPS is not enable then it will be on
> if(!isGPS)
> {
> Intent intent = new
> Intent("android.location.GPS_ENABLED_CHANGE");
> intent.putExtra("enabled", true);
> sendBroadcast(intent);
> }
> mlocManager.requestLocationUpdates(
> LocationManager.GPS_PROVIDER,
> 0, 0, locationListener);
> }
>
> private final LocationListener locationListener = new
> LocationListener() {
>
> public void onLocationChanged(Location location) {
>
> updateWithNewLocation(location);
> }
>
> public void onProviderDisabled(String provider) {
> updateWithNewLocation(null);
> }
>
> public void onProviderEnabled(String provider) {
> }
>
> public void onStatusChanged(String provider, int status,
> Bundle extras) {
> }
> };
>
> private void updateWithNewLocation(Location location) {
>
> String latLongString = "";
> if (location != null) {
> double lat = location.getLatitude();
> double lng = location.getLongitude();
> latLongString = "Lat:" + lat + "\nLong:" + lng;
>
>
>
> } else {
> latLongString = "No location found";
> }
> Toast.makeText(getBaseContext(),latLongString,
> Toast.LENGTH_SHORT).show();
>
> }
> and this is permission i use
> <uses-permission android:name="android.permission.INTERNET" />
> <uses-permission
> android:name="android.permission.ACCESS_FINE_LOCATION"/>
> <uses-permission
> android:name="android.permission.ACCESS_COARSE_LOCATION"/>
>
> this code dont have any error message but it dont have right output.
> this is because onLocationChange method not called. i wondder how. can
> some one help me?
>
> ~Alfa
--
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