Problem: I see the satilite icon on the top of the phone, but when I send the device multiple coordinates, is never runs the onLocationChange method.
Assumptions: Ignore the "WakefulIntentService". Its just a modification of the service class, by Mark Murphy, that keeps the service running.
Question: Why isn't the emulator / my phone triggering onLocationChange, but displaying an icon signifying GPS is active when onHandleIntent is called? (And until stopUpdates is called). And, what can I do to fix this?
Code (FmiLocationManager.java):
Using java Syntax Highlighting
- package org.myProj;
- import android.content.Context;
- import android.content.Intent;
- import android.location.LocationManager;
- import android.location.Location;
- import android.location.LocationListener;
- import android.os.Bundle;
- import android.os.IBinder;
- import android.util.Log;
- import android.location.Criteria;
- public class FmiLocationManager extends WakefulIntentService implements LocationListener
- {
- private LocationManager locationMan;
- private LocationListener locationLis;
- public FmiLocationManager()
- {
- super("FmiLocationManager");
- }
- @Override
- protected void onHandleIntent(Intent intent) {
- super.onHandleIntent(intent);
- locationMan = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
- String provider = "gps"; //(Available on the emulator, I tested it)
- locationMan.requestLocationUpdates(
- provider,
- 13000,
- 3,
- this);
- }
- }
- public void onStop()
- {
- stopUpdates();
- }
- public void stopUpdates()
- {
- if(locationLis != null)
- locationMan.removeUpdates(locationLis);
- }
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
- public void onLocationChanged(Location loc) {
- Log.e("fmi","fmi new location received");
- //NEVER gets sent.
- }
- public void onProviderDisabled(String provider) {
- }
- public void onProviderEnabled(String provider) {
- }
- public void onStatusChanged(String provider, int status,
- Bundle extras) {
- }
- }
Parsed in 0.037 seconds, using GeSHi 1.0.8.4
Manifest:
I won't post the entire thing, but here is the important information:
Using xml Syntax Highlighting
- android:versionName="1.0"
- android:versionCode="1"
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
- <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-permission>
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
- <uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
- <service android:name=".FmiLocationManager" />
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
------------------------------------------------------------------------


