udacity/Just-Java

Problem with resolveActivity() method

Closed this issue · 1 comments

app/src/main/java/com/example/android/justjava/MainActivity.java

Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_SUBJECT,
getString(R.string.order_summary_email_subject, name));
intent.putExtra(Intent.EXTRA_TEXT, message);

    **if (intent.resolveActivity(getPackageManager()) != null)** {
        startActivity(intent);

In my phone, the Gmail App opens when
if (intent.resolveActivity(getPackageManager()) == null) is used instead of
if (intent.resolveActivity(getPackageManager()) != null) (note ==null and !=null)

Can anybody explain the possible reason for this?

@devayush20 We recommend you use the https://knowledge.udacity.com/ for specific issues and clarifications.