Implementing the permissions request for READ_CONTACTS


#1

Hi @cstewart,

Google’s Android documentation has this article on requesting permissions at run time however it is full of boiler plate code.

I would like to get your input on the cleanest way to check, request and evaluate a users response to a permission request


#2

In chapter 33 of the book, we talk about how to use run time permissions. I’d recommend that you check that out.

If you have any questions about it, please post them here.


#3

I got it to work. Thanks for the tip. I would recommend that for future versions of the book that you could provide a hint in the challenge to look at chapter 33 to see how permissions are checked, requested and results acted upon


#4

Good idea. Thanks for the feedback!


#5

Hello,could you help find the problem in the following code when I tried to finish the homework of ch15.5(about the usage of the ShareCompat.IntentBuilder class)

code:

mReportButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {

            ShareCompat.IntentBuilder sc = ShareCompat.IntentBuilder.from(getActivity());
            sc.setType("text/plain");
            sc.setText(getCrimeReport());
            sc.setSubject(getString(R.string.crime_report_subject));
            sc.createChooserIntent();
            sc.startChooser();

        /*    Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_TEXT, getCrimeReport());
            i.putExtra(Intent.EXTRA_SUBJECT,
                    getString(R.string.crime_report_subject));
            i = Intent.createChooser(i, getString(R.string.send_report));
            startActivity(i);
            */
        }
    });

The result:
When I tried to use the ShareCompat.IntentBuilder to replace the original code, I found that the system require you to reinstall the app in the first time you run it. After the app reinstalled, the page will automatically jump into the activity of sending email when I press the “add menu” in the crimelistactivity page, without any more operation.(Here, I supposed that it should jump into the page of crimepagerview activity and wait me to press the send-report button.)
You can paste the code provided above and run it to see the problem. Thank you.


#6

I have solved the problem that located in carelessness that I have paste the new code twice in project and one of the copy is outside the mReportButton.setOnClickListener() method.

Anyway, thank you.