Can't figure out the solution to the easy challange

The normal intent was: final Intent pickContact = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
How on earth doesn’t this show the view of the normal intent?:
Intent intent = ShareCompat.IntentBuilder.from(getActivity()).setStream(ContactsContract.Contacts.CONTENT_URI).setSubject(Intent.ACTION_PICK).setType(ContactsContract.Contacts.CONTENT_TYPE).createChooserIntent();

I think you are referring to the Challenge 1: ShareCompat :thinking: The challenge specifically informs that the challenge is meant for the report button. When you explore the ShareCompat.IntentBuilder class, it clearly informs that the aforementioned class is only useful for constructing intents that either has a ACTION_SEND or ACTION_SEND_MULTIPLE action on it. The ShareCompat.IntentBuilder uses a fluent interface just like FragmentManager. So, you would construct the intent like below:

reportButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = ShareCompat.IntentBuilder.from(getActivity())
                    .setType("text/plain")
                    .setChooserTitle(getString(R.string.send_report))
                    .setSubject(getString(R.string.crime_report_subject))
                    .setText(getCrimeReport())
                    .createChooserIntent();
            startActivity(i);
        }
    });

Happy learning/coding :+1:

2 Likes

Thank you ,that was helpful :slight_smile:

1 Like