Profile

Cover photo
Luis Fernando Cugliandro
Works at Resource IT Solutions
Lives in São Paulo
160 followers|118,190 views
AboutPostsPhotosYouTubeReviews

Stream

 
 
Why runtime permissions shouldn’t scare you
Pro-tip by +Joanna Smith

Marshmallow introduced Runtime Permissions, and that seems to be all anyone is talking about this summer. But that’s because prompting for a long list of permissions at install can intimidate users, and that’s not good for anyone. So apps targeting Marshmallow now have to put these permission requests into a context, by asking for them when the user is trying to use the relevant feature.

As great as this is, I’m sure that you’ve thought to yourself “that’s okay, I just won’t update to Marshmallow until I have to.” Updating your app isn’t as daunting as you might think, though. You simply need add a few lines of code that build in checks and graceful failures. So here’s a handy guide to walk you through it.

Step 1: check the platform. If the device is running Lollipop or earlier, then the user granted permission at install time, and you’re good to go. But if the device is running Marshmallow, you can’t be so certain. Clever developers can use the support library, though, which will do this check for you. That’s one less line of code for you to add.

Which brings us to step 2: check the permission status. A simple call to checkSelfPermission() (http://goo.gl/T7vE7b) will let you know if the permission is currently granted. The only scary thing here is that you can’t rely on assumptions here, because even if the user granted the permission in the past, they may have revoked it later on. So with one conditional statement, you’ve completed step 2.

If you don’t have permission, you may need step 3: explain the permission. In some instances, you’ll want to update the UI to clarify what that permission enables and why the feature needs it. This can be as simple as a toast or as complex as the fanciest layout. The cool thing here is that you don’t need to figure out what those moments are. A call to shouldShowRequestPermissionRationale() (http://goo.gl/bFyfVj) will indicate whether this is one of those clarifying moments. Easy enough, right?

And now, the heart of it-- step 4: request the permission. The requestPermissions() (http://goo.gl/yNuizg) method will prompt a dialog to the user to get their answer and then trigger your onRequestPermissionResult() callback to handle the response. This is only two lines of code to add. One to make the call, and one to declare the request code, which is indicative of where the user is in your app and what they are trying to do.

Finally, step 5: handle the response. Here is your biggest change, and all it is is overwriting your callback with a switch statement based on that request code. Your request code will help you restore the app to the right state if the permission has been granted. If the user rejected the request, though, you’ll need to update the UI to disable the feature or indicate that it won’t be available without the permission.

So, you see, it isn’t so scary to add support for runtime permissions. Take a crack at it and #BuildBetterApps ! And if you want some more context and implementation guidelines, check out the blog post from last week (http://goo.gl/JMnKQw).
28 comments on original post
1
Add a comment...
 
Download #Timely, use HKAU-AB07-1DFD and get a theme for free! http://r.bitsp.in/HKAUAB071DFD
Get Timely on Google Play and get a theme for free! Referral Code: HKAUAB071DFD
1
Add a comment...
 
Simplesmente sensacional.. 
 ·  Translate
1
Add a comment...
 
 
#AndroidDev , +Reto Meier is here to give you your weekly update on Android Development!

YouTube:
This Week in Android Development - July 22nd 2013

Last Week:
Google Play Games Show: To The Web (and Beyond!) - http://goo.gl/dauLG
Android Design in Action: GDG Oslo + Design Consistency - http://goo.gl/xVH7e
Android Developers Backstage: Making Apps Beautiful - Part 1 - http://goo.gl/EQONS
DevBytes: Making Apps Beautiful - Part 3: Tablets - http://goo.gl/Pp9Yi
DevBytes: Anticipation and Overshoot - Part 1 - http://goo.gl/NkOnb
Android Developer Survey - http://goo.gl/nkTno

Coming up this week:
DevBytes: Making Apps Beautiful - Part4: Performance Tuning - http://goo.gl/D6xvu
DevBytes: Anticipation and Overshoot - Part 2 - http://goo.gl/TZz8G
App Clinic - http://goo.gl/MoXYI

Apps
Tinder - http://goo.gl/uUEna
2 comments on original post
1
Add a comment...
 
 
You can now easily generate navigation drawer indicators in the Android Asset Studio. Comes with built-in Holo Dark and Holo Light support, and you can customize the color to fit your app's theme as well.

http://android-ui-utils.googlecode.com/hg/asset-studio/dist/icons-nav-drawer-indicator.html

Use this as the drawerImageRes in the ActionBarDrawerToggle [1] constructor.

[1] https://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.html

#AndroidDesign   #AndroidDev  
13 comments on original post
1
Add a comment...
 
 
Tutorial Video Building a Mobile App with AngularJS and Ionic Framework Tutorial
https://codek.tv/7009

#mobileapp
View original post
1
Add a comment...
 
 
Why more the reason now to #Switch :) Have a good weekend folks!!!

#Nokia #iPhone #Humour 
1
Add a comment...
 
 
Another day, another update to the Asset Studio's nine-patch generator! The new interactive nine-patch preview feature lets you preview your stretch region and content padding to make sure they work at all sizes. Simply drag to resize and see your nine-patch and optional text content in action! A screencast of the new feature is attached to this post.

Nine-patch generator: http://goo.gl/QBjiX

#AndroidDesign
21 comments on original post
1
Add a comment...
 
Sensacional..
1
Add a comment...
 
 
You can now easily generate navigation drawer indicators in the Android Asset Studio. Comes with built-in Holo Dark and Holo Light support, and you can customize the color to fit your app's theme as well.

http://android-ui-utils.googlecode.com/hg/asset-studio/dist/icons-nav-drawer-indicator.html

Use this as the drawerImageRes in the ActionBarDrawerToggle [1] constructor.

[1] https://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.html

#AndroidDesign   #AndroidDev  
13 comments on original post
9
2
Add a comment...
Work
Occupation
Desenvolvedor Java - Android
Skills
Java Android
Employment
  • Resource IT Solutions
    2011 - present
Basic Information
Gender
Male
Melhor restaurante de comida japonesa da região!!!
Public - 2 months ago
reviewed 2 months ago
Bom lugar para se hospedar em SP
Public - 5 months ago
reviewed 5 months ago
Pessoal muito legal e muito rock n' roll!!
Public - 5 months ago
reviewed 5 months ago