I am trying to make a simple android app in which there is a toast message containing the number of the incoming call. I have stored the number in a string variable. When I display just the toast, it works fine but before the toast, if I add a simple if condition comparing the number to another string, the app quits. The required permissions are given. Can someone help me?
This Works:
public void onReceive(Context context, Intent intent) {
        String incomingNumber = intent.getExtras().getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
        Toast.makeText(context, incomingNumber, Toast.LENGTH_LONG).show();
    }
This Does not Work (App quits)
public void onReceive(Context context, Intent intent) {
        String incomingNumber = intent.getExtras().getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
          if(incomingNumber.equals("+919999999999"))
           {
              Toast.makeText(context, "Call from Mom", Toast.LENGTH_LONG).show();
           }
           else
           {
              Toast.makeText(context, incomingNumber, Toast.LENGTH_LONG).show();
           }
    }
