GPS without network access?

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

GPS without network access?

Postby claudette » Tue Feb 23, 2010 4:16 pm

I am using the Motorola Milestone (Droid).

I need to use GPS without network connection. But after I set a GPS location listener, I get the network error "Unresolved host address" (see below). On the device I do not have any network access at the time I try to start the GPS localisation. Is there no way to use GPS without network access?

Best regards,

claudette

LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mLocationListener);


02-19 16:35:13.928: ERROR/SUPLJ(1166): IOException
02-19 16:35:13.928: ERROR/SUPLJ(1166): java.io.IOException: Unresolved host address!
02-19 16:35:13.928: ERROR/SUPLJ(1166): at com.motorola.android.locationproxy.SuplDataService.openPlainTextConnection(SuplDataService.java:255)
02-19 16:35:13.928: ERROR/SUPLJ(1166): at com.motorola.android.locationproxy.SuplDataService.handleMessage(SuplDataService.java:113)
02-19 16:35:13.928: ERROR/SUPLJ(1166): at android.os.Handler.dispatchMessage(Handler.java:99)
02-19 16:35:13.928: ERROR/SUPLJ(1166): at android.os.Looper.loop(Looper.java:123)
02-19 16:35:13.928: ERROR/SUPLJ(1166): at com.android.server.LocationProxyService.run(LocationProxyService.java:344)
02-19 16:35:13.928: ERROR/SUPLJ(1166): at java.lang.Thread.run(Thread.java:1096)
claudette
Freshman
Freshman
 
Posts: 7
Joined: Thu Nov 19, 2009 11:58 am

Top

Postby djmason9 » Tue Feb 23, 2010 11:54 pm

this works but make sure you add the correct permissions in your manifest

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.      package="com.map"
  6.  
  7.      android:versionCode="1"
  8.  
  9.      android:versionName="1.0">
  10.  
  11.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  12.  
  13.         <activity android:name=".MapTestView"
  14.  
  15.                  android:label="@string/app_name">
  16.  
  17.             <intent-filter>
  18.  
  19.                 <action android:name="android.intent.action.MAIN" />
  20.  
  21.                 <category android:name="android.intent.category.LAUNCHER" />
  22.  
  23.             </intent-filter>
  24.  
  25.         </activity>
  26.  
  27.                 <uses-library android:name="com.google.android.maps" />
  28.  
  29.     </application>
  30.  
  31.    
  32.  
  33.     <uses-sdk android:minSdkVersion="7" />
  34.  
  35.         <uses-permission android:name="android.permission.INTERNET" />
  36.  
  37.         <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  38.  
  39.  
  40.  
  41. </manifest>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  2.  
  3.                 Criteria criteria = new Criteria();
  4.  
  5.                 criteria.setAccuracy(Criteria.ACCURACY_FINE);
  6.  
  7.                 criteria.setAltitudeRequired(false);
  8.  
  9.                 criteria.setBearingRequired(false);
  10.  
  11.                 criteria.setCostAllowed(true);
  12.  
  13.                 criteria.setPowerRequirement(Criteria.POWER_LOW);
  14.  
  15.                 String provider = locationManager.getBestProvider(criteria, false);
  16.  
  17.                 Location location = locationManager.getLastKnownLocation(provider);
  18.  
  19.                 updateWithNewLocation(location);
  20.  
  21.                 locationManager.requestLocationUpdates(provider, 2000, 10, locationListener);
  22.  
  23.  
  24.  
  25.  
  26.  
  27.                 mc = mapView.getController();
  28.  
  29.                 // mc.animateTo(p);
  30.  
  31.                 p =
  32.  
  33.                         new GeoPoint(
  34.  
  35.                                 (int) (locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLatitude() * 1000000),
  36.  
  37.                                 (int) (locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLongitude() * 1000000));
  38.  
  39.                 mc.setZoom(14);
  40.  
  41.                 mc.animateTo(p);
  42.  
  43. mapView.invalidate();
  44.  
  45.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
djmason9
Freshman
Freshman
 
Posts: 3
Joined: Tue Feb 23, 2010 11:38 pm

motorola milestone: gps without network?

Postby claudette » Wed Feb 24, 2010 3:06 pm

thank you for your response djmason9!

but unfortunately it doesn't work on a motorola milestone! are you using a motorola milestone?
if I run the application on a samsung mobile, I get the latitude and longitude values.
it seems as if the error is been caused by a motorola class.

has anybody noticed that problem and has a solution?

thank you!

kind regards,
claudette
claudette
Freshman
Freshman
 
Posts: 7
Joined: Thu Nov 19, 2009 11:58 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 3 guests