Skip to Content
Android 9 Development Cookbook - Third Edition
book

Android 9 Development Cookbook - Third Edition

by Rick Boyer
October 2018
Intermediate to advanced
464 pages
15h 17m
English
Packt Publishing
Content preview from Android 9 Development Cookbook - Third Edition

How it works...

The access request is handled by the OS, not by the app. To request access, we need to call createAccessIntent(), which we do with this line of code:

Intent intent = storageVolume.createAccessIntent(Environment.DIRECTORY_MUSIC);

We call the Intent using the startActivityForResult() method, which we’ve used before. Since we are looking for a result to come back, we need to pass a unique identifier to know when the returned result callback is from our request. (The onActivityResult() callback method can receive callbacks for multiple requests.) If the request code matches our request, we then check whether the result code equals Activity.RESULT_OK, which means the user granted the permission request. We pass the result to

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Android Application Development Cookbook - Second Edition

Android Application Development Cookbook - Second Edition

Rick Boyer, Kyle Mew
Android High Performance Programming

Android High Performance Programming

Enrique López Mañas, Diego Grancini
Android Things Projects

Android Things Projects

Francesco Azzola

Publisher Resources

ISBN: 9781788991216Supplemental Content