Tuesday, December 22, 2009

[android-developers] Re: ($25 reward) GPS not triggering onLocationChanged

Thanks a lot for your support everyone!

I winded up doing many things, most of which were required for this to
work.

1. Used the WakefulIntentService, and at the bottom of onHandleIntent,
manually called onStop
2. Right away I created a wakelock
3. BEFORE the first requestLocationUpdates(yadaa yadda yadda, this) I
called releaseUpdates(this).
4. Removed the accidental duplicate requestLocationUpdates
5. Added a sleep timer to onHandleIntent, and had it call onStop
afterwards (releases the wakelock and locationupdates)

The main issue was keeping the service awake, second issue was all the
stupid bugs in the 1.5 OS.

On Dec 19, 11:17 pm, Ipsemet <worldsflir...@gmail.com> wrote:
> To my knowledge, the emulator doesn't emulate sensors.
>
> On Dec 19, 9:46 pm, dapaintballer331 <dapaintballer...@gmail.com>
> wrote:
>
>
>
> > If somebody can get this to work for me, using an emulator on the 1.5
> > sdk, I will send them $25 via paypal if you need it. I am using the
> > android 1.5 emulator.
>
> > 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):
> > =========code=========
> > 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);
> >                 locationMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
> > 0, this);
> >                 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) {
> >          }}
>
> > ==========end code========
>
> > Manifest:
> > I won't post the entire thing, but here is the important information:
> > 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" />
>
> > ------------------------------------------------------------------------

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate