Hi, Kristopher Thank you for your reply. The test I did before is indoor. After someone give me a hint, I do a test outdoor, it worked, it can get the position. To get the first point of position, I waited around 15 minutes.
Thanks and Regards, Kenneth On 10月31日, 下午6時55分, Kristopher Micinski <[email protected]> wrote: > And you were also outside during these 15 minutes? > > Kris > > > > > > > > On Mon, Oct 31, 2011 at 1:01 AM, Kenneth WON <[email protected]> wrote: > > Hi, Kristopher, > > > Thank you for your reply. Yes, I waited it more than 15 minutes. And > > following is my code, I have no idea where's wrong, please feel free > > to have a look, and If you don't mind, please give me some hints Thank > > you! > > > import android.app.Service; import android.content.Intent; import > > android.location.Location; import > > android.location.LocationListener; import > > android.location.LocationManager; import android.os.Binder; import > > android.os.Bundle; import android.os.Handler; import > > android.os.IBinder; import android.util.Log; public class GPSService > > extends Service implements LocationListener { private Handler > > requestLocUpdateHandler = new Handler(); private LocationManager > > locationMgr; private static int locUpdateTime = 30000; // Bind for > > Service Connection class GPSServiceBinder extends Binder { > > GPSService getService() { return GPSService.this; } } // > > define ACTION public static final String ACTION = "GPS Service > > Broadcast"; @Override public void onCreate() { > > super.onCreate(); locationMgr = > > (LocationManager) getSystemService(LOCATION_SERVICE); > > requestLocUpdateHandler.postDelayed(requestLocUpdateTask, 1000); } > > private void updateLocStatus(Location loc) { if (loc != null) { > > double latitude = loc.getLatitude(); double longitude = > > loc.getLongitude(); long locTime = loc.getTime(); String > > dateTime = Utils.dateFormat.format(locTime); Log.w("Location > > Info", loc.getAccuracy() + " | " + loc.getProvider()); > > Log.w("GPS", "Time: " + dateTime + " | Lat: " + latitude + " | Long: " > > + longitude); } } private Runnable requestLocUpdateTask = new > > Runnable() { @Override public void run() { > > requestLocUpdate(); > > requestLocUpdateHandler.postDelayed(requestLocUpdateTask, locUpdateTime); > > } }; private void requestLocUpdate() { > > locationMgr.removeUpdates(this); > > locationMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, > > 0, this); } @Override public IBinder onBind(Intent arg0) { > > return new GPSServiceBinder(); } @Override public void > > onRebind(Intent intent) { } @Override public boolean > > onUnbind(Intent intent) { return true; } @Override public > > void onLocationChanged(Location location) { > > updateLocStatus(location); } @Override public void > > onProviderDisabled(String provider) { } @Override public void > > onProviderEnabled(String provider) { } @Override public void > > onStatusChanged(String provider, int status, Bundle extras) { } > > @Override public void onDestroy() { super.onDestroy(); > > locationMgr.removeUpdates(this); } @Override public void > > onStart(Intent intent, int startId) { super.onStart(intent, > > startId); } } > > Thanks and Regards, Kenneth Won > > > On 10月31日, 上午11時22分, Kristopher Micinski <[email protected]> > > wrote: > >> Cold starts can take up to 15 minutes... > > >> Did you wait 15 minutes... > > >> On Sun, Oct 30, 2011 at 11:17 PM, Kenneth WON <[email protected]> wrote: > >> > Hi, lbendlin, > > >> > Thank you for your reply. > >> > I am really facing this issue. > >> > When I turn off the Network (WiFi and/or cell network), the app cannot > >> > obtain (GPS / A-GPS) position. > >> > Then I turn the network on, it can get the (GPS / A-GPS) position > >> > successfully. > >> > What's wrong? > > >> > Thanks and Regards, > >> > Kenneth Won > > >> > On 10月31日, 上午8時30分, lbendlin <[email protected]> wrote: > >> >> GPS can work very well without internet access - after it got the first > >> >> fix. The internet access is used to download satellite position data to > >> >> the GPS receiver which speeds up the TTFF (time to first fix). Without > >> >> the > >> >> extra help the first fix can take quite some time, especially when you > >> >> are > >> >> already moving. > > >> >> Go to a location with unobstructed sky view and let the GPS receiver > >> >> get a > >> >> fix. Then check how it performs on subsequent fixes. > > >> > -- > >> > 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 > > > -- > > 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 -- 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

