Dan & Devin,

I see this same behavior, but only on my slow development system,
never on my fast development system. I concluded that this was a
timing bug in the SDK / emulator and gave up trying to do anything
about it.

The ADC judges will have to be aware of this anomaly, and many more,
and hopefully not penalize too harshly for behavior beyond our
control. :-)

Jim Renkel

On Apr 8, 3:51 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Thanks for the reply.
>
> I'm pretty sure the unregister/removeUpdate are getting called
> successfully, because if they weren't I would get an exception next
> time they are registered/requested (I found out because I commented
> out the calls and got this when they were registered/requested again
> in onResume.)
>
> Most typically, after I close the app with either the Android Home
> button or Back button, about 7 seconds later I get the "broadcast
> null" exception.  I believe that is after the onDestroy gets called.
> I used to unregister in onFreeze (and register in onResume), and that
> would get the exception right when the app went away instead of after
> a delay.
>
> Yes, my machine is on the slow side.  It's strong enough to run Vista,
> bet it is near the bottom of the requirements.
>
> I've really spent some time trying to get to the bottom of this and
> have followed the other threads on this.  I learned a lot about how
> this works in the thread you mentioned...  It was invaluable.  But I
> still have problems.  I was suspecting that there was something fishy,
> so I tried to be extra certain by, for example, creating the variable
> "private static final String LOCATION_CHANGED_ACTION = new
> String("android.intent.action.LOCATION_CHANGED")" to make certain they
> are calling the respective register/request/unregister with the same
> value...  to no avail.
>
> Devin Dow
>
> On Apr 8, 9:03 am, "Dan U." <[EMAIL PROTECTED]> wrote:
>
> > We had a discussion about this sort of thing 
> > here:http://groups.google.com/group/android-developers/browse_thread/threa...
> > but your code looks fine to me. In fact, I can't seem to reproduce.
> > You say it takes a few runs? I ran it a few times and didn't see the
> > problem. By any chance do you have a slow development machine? I'm
> > wondering if mine is fast enough that I don't see some kind of race
> > condition.
>
> > It almost looks like onFreeze isn't getting called when you have this
> > problem. Either that or the removeUpdates call isn't successful.
>
> > On Apr 8, 7:11 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > > Would someone post code that successfully removes updates and
> > > unregisters receivers without ever getting the broadcast null crash?
>
> > > I have tried every imaginable combination of changes, including a
> > > boolean on variable, but with a few runs of the app, it still
> > > eventually gives this crash after I close, even when wiping data on
> > > the emulator.
>
> > > Here's my current relevant code:
>
> > >     private LocationManager locationManager;
> > >     private LocationIntentReceiver intentReceiver = new
> > > LocationIntentReceiver();
> > >     private static final String LOCATION_CHANGED_ACTION = new
> > > String("android.intent.action.LOCATION_CHANGED");
> > >     private IntentFilter intentFilter = new
> > > IntentFilter(LOCATION_CHANGED_ACTION);
> > >     private Intent intent = new Intent(LOCATION_CHANGED_ACTION);
>
> > >     @Override
> > >     public void onCreate(Bundle icicle) {
> > >         super.onCreate(icicle);
> > >         setContentView(R.layout.main);
>
> > >         locationManager =
> > > (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
> > >         registerReceiver(intentReceiver, intentFilter);
> > >     }
>
> > >     public class LocationIntentReceiver extends IntentReceiver{
> > >         @Override
> > >         public void onReceiveIntent(Context context, Intent intent) {
> > >                 if (startLocation == null)
> > >                         return;
>
> > >                         //Location currentLocation = 
> > > (Location)intent.getExtra("location");
> > >                         Location currentLocation =
> > > locationManager.getCurrentLocation("gps");
>
> > >                                                 ...
> > >                                            }
> > >     }
>
> > >     @Override
> > >     public void onResume() {
> > >         super.onResume();
> > >                 List<LocationProvider> providers = 
> > > locationManager.getProviders();
> > >                 LocationProvider locationProvider = providers.get(0);
> > >                 locationManager.requestUpdates(locationProvider, 0, 0, 
> > > intent);
> > >     }
>
> > >     @Override
> > >     public void onFreeze(Bundle icicle) {
> > >         locationManager.removeUpdates(intent);
> > >         super.onFreeze(icicle);
> > >     }
>
> > >     @Override
> > >     public void onDestroy() {
> > >         unregisterReceiver(intentReceiver);
> > >         super.onDestroy();
> > >     }- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to