0

I am getting the following error:

Attempt to invoke virtual method 'boolean java.lang.String.contains(java.lang.CharSequence)' on a null object reference

on the following lines:

protected void onPostExecute(String s) {
        super.onPostExecute(s);
        if (s.contains("Error")) {
            pd.dismiss();
            return;
        }

In Particular, this line:

 if (s.contains("Error")) {

I don't believe I am missing any code, but a second set of eyes would be much appreciated.

1 Answers1

0
 if(s!= null && !s.isEmpty()&&s.contains("Error")) {
        pd.dismiss();
        return;
    }
sasikumar
  • 12,540
  • 3
  • 28
  • 48
  • isEmpty() also performs a null check so a bit long winded. – Ivan Wooll Sep 18 '18 at 07:03
  • While this might answer the authors question, it lacks some explaining words and links to documentation. Raw code snippets are not very helpful without some phrases around it. You may also find [how to write a good answer](https://stackoverflow.com/help/how-to-answer) very helpful. Please edit your answer. – hellow Sep 18 '18 at 08:07