i'm pretty sure it's impossible to guarantee something like that... i don't think part of their new programmer orientation is "if you ever touch the code that runs BroadcastReceiver.onReceive...never send a null intent".
Either way, at least on android 4.2.2_r1, it seems like it's impossible to get a null intent. feel free to verify this is true for all previous versions as well (and don't forget to keep checking this method every time they make a new build). http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.2.2_r1/android/app/ActivityThread.java#2335 On Thursday, July 11, 2013 4:09:27 PM UTC+3, Palmer Eldritch wrote: > > That's nice advice - but in this case I think one should have a guarantee > > Does it make sense to receive a null intent ? Is it even possible with the > current android code ? > > On Thursday, July 11, 2013 9:46:00 AM UTC+3, Piren wrote: >> >> No point of being sure here... even if the current code is structured in >> a way that it shouldn't be null, nothing says it will stay like that in all >> future code revisions. >> Ever since i started getting null exceptions from android (not >> NullPointerException... a Null instead of an exception) i learned it's >> always a good idea to check for nulls when you're supposed to receive an >> object. >> >> On Thursday, July 11, 2013 6:01:13 AM UTC+3, Palmer Eldritch wrote: >>> >>> I suspect it can't be null *by construction* - I just can't pin it down >>> in code (or in docs) >>> >>> It's nice to be sure >>> >>> Can somebody point to the relevant code parts ? >>> >>> I mean what paths lead to the onReceive being triggered ? Can we have a >>> null intent in any of them ? >>> >>> On Thursday, July 11, 2013 4:18:09 AM UTC+3, TreKing wrote: >>>> >>>> >>>> On Wed, Jul 10, 2013 at 4:14 PM, Palmer Eldritch <[email protected]>wrote: >>>> >>>>> I mean nobody knows ?? >>>>> >>>>> Do you ever check the intent for being null and if not why ? >>>>> >>>> >>>> Here's what you do. Assume it will not be null, then use ACRA or some >>>> other bug-reporting tool to handle uncaught exceptions. If you get a null >>>> pointer exception from here, you know it can be null. >>>> >>>> You're welcome. >>>> >>>> >>>> ------------------------------------------------------------------------------------------------- >>>> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago >>>> transit tracking app for Android-powered devices >>>> >>> -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

