Ashkan Mobayen Khiabani Ashkan Mobayen Khiabani - 2 months ago 5
Android Question

Android studio highlights an area, without any errors in the code

I'm new to android studio. I just added

for a
and the background color of the code for listener turns brown (somehow like a selection):

enter image description here

What does this color mean?
Is it normal or is it indicating a problem?
And how can I make it go away because its really annoying.


This is caused by the Android Studio trying to warn you that some method invocation may produce some exception (usually a NullPointerException). You can fix this by adding an if check for each thing like:

if(myThing != null){
    //do stuff

Or simply by adding before using myThing:

assert myThing != null;

Check this and maybe this question for further improving your insight on this.