Pro Android with Kotlin


CHAPTER 6: Content Providers


Download 5.42 Mb.
Pdf ko'rish
bet93/223
Sana04.11.2023
Hajmi5.42 Mb.
#1746807
1   ...   89   90   91   92   93   94   95   96   ...   223
Bog'liq
@de android telegram Pro Android with Kotlin Developing Modern Mobile

101
CHAPTER 6: Content Providers
// The ACTION_OPEN_DOCUMENT intent was sent with the
// request code READ_REQUEST_CODE. If the request
// code seen here doesn't match, it's the
// response to some other intent, and the code below
// shouldn't run at all.
if (requestCode == READ_REQUEST_CODE
&& resultCode == Activity.RESULT_OK) {
// The document selected shows up in
// intent.getData()
val uri = resultData.data
Log.i("LOG", "Uri: " + uri.toString())
showImage(uri) // Do s.th. with it
}
}
Instead of opening a file as shown in the example, you can do other things with the URI 
you received in the intent’s return. You could, for example, also issue a query to fetch 
metadata as shown in the previous query methods. Since the DocumentsProvider inherits 
from ContentProvider, you can use the methods described earlier to open a stream for the 
document’s bytes.


103
© Peter Späth 2018 
P. Späth, Pro Android with Kotlin, 
https://doi.org/10.1007/978-1-4842-3820-2_7
Chapter
7
Permissions
Securing sensitive data is an important task during the development of apps. With more and 
more apps on handheld devices being used for sensitive everyday tasks such as banking, 
security has been gaining more importance, and it will continue to do so in the future. You as 
a developer must take every precaution possible to handle your app users’ data responsibly.
Fully covering every possible security aspect is a challenging task and would fill a whole 
book on its own. Fortunately, there is a vast number of online resources you can consult to 
get updated with Android OS security matters. Just be cautious to filter out inappropriate 
information. The following security-related topics in the Android OS’s online resources are a 
good place to start:
https://developer.android.com/training/best-security.html
https://developer.android.com/training/best-permissions-ids.html
If these links are broken when you read the book, search for android best practices security 
and android best practices permissions in your favorite search engine and you’ll readily find 
these resources.
Having said that, we still want to thoroughly deal with the permission system inside the 
Android OS because this is the place you as a developer will definitely have to feel at home 
once your app addresses sensitive data. Permissions add security to system data and 
features; you can use predefined permissions, define them yourself, or declare them by 
writing appropriate entries in AndroidManifest.xml.
Permission Types
Permissions come in several flavors according to the desired protection level.

Normal: This level corresponds to low-level security-sensitive 
information. The system will automatically grant such permissions 
without explicitly asking the user, but the permission is listed in the 
package description and can be queried by explicit demand using the 
system settings app.



Download 5.42 Mb.

Do'stlaringiz bilan baham:
1   ...   89   90   91   92   93   94   95   96   ...   223




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling