The framework code that Piren posted a link to above (below?) accesses
the Intent object before calling the receiver's onReceive:

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.2.2_r1/android/app/ActivityThread.java#2350

Line 2350:

data.intent.setExtrasClassLoader(cl);

This code will crash inside the framework if the intent is null.

However, this is a specific version of *stock* Android... Other
versions, including manufacturer specific or custom ROMs may, in
theory, be different.

Weird things do happen though, when you have an app in Play and it
gets installed on a fair number of different devices. I recall one
crash report in Play where the framework was complaining about not
being able to find the application's .apk while instantiating the
Application subclass object (or something equally absurd). Over time,
you learn to not worry about these too much.

-- K

2013/7/15 Palmer Eldritch <the.u...@gmail.com>:
> Glad you agree with each other
>
> Have you thought that this could be a way of delving a bit deeper into the
> framework ? That, well, it's not the end result only but the search that
> matters ?
>
> And that maybe this way one writes code faster at the end cause one knows
> his/her way better ?
>
> No
>
> Receiving an object one hasn't the slightest idea about is apparently the
> android way - may be null or not - who cares as long as we can add an if
>
> Even in one of the most fundamental callbacks
>
> Maybe have a look at my links after all ?
>
>
> On Tuesday, July 9, 2013 3:46:41 PM UTC+3, Palmer Eldritch wrote:
>>
>> In other words :
>>
>>     @Override
>>     public void onReceive(Context context, Intent intent) {
>>         final String action = intent.getAction(); // can intent==null here
>> ?
>>     }
>>
>> I need to solve this once and for all so please no ifs and buts. I would
>> check for null but I suspect that it is not needed and therefore it is
>> clumsy and inelegant to check. I had searched in the docs but have not found
>> anything
>
> --
> --
> 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+unsubscr...@googlegroups.com
> 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 android-developers+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
-- 
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+unsubscr...@googlegroups.com
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 android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to