Without additional annotations, static analysis is going to warn that both
the Context and Intent may be null. This is due to the fact that the
broadcast receiver is an instantiable class and onReceive() is a public
method. For example:
new MyBroadcastReceiver().onReceive(null, null);
Adding @NonNull to the two parameters will allow you to forego null checks,
but you better hope the framework never calls onReceive() with null
arguments.
On Tuesday, July 9, 2013 2:46:41 AM UTC-10, Mr&Mrs D 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 [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/d/optout.