Android Marshmallow Permissions Example

Hello friends, welcome to this new tutorial. Today I will show you Android Marshmallow Permissions Example. One of the major changes in Android Marshmallow is the new permission system. In earlier versions we were declaring the permission in the AndroidManifest.xml file. But with Android Marshmallow we need to ask the permission at run time.  In this post I will show you a simple Android Marshmallow Permissions Example. So lets begin.

Android Marshmallow Permissions Example Video

You can watch this video before moving to the Android Marshmallow Permissions example. This is video is the demonstration of the final output.

Android Marshmallow Permissions Example Project

  • Open Android Studio and create a new Android Project. Select Empty Activity come to your project window. After these steps (we do it always :P).
  • In this example I will try to ask the permission for READING EXTERNAL STORAGE. So go to your AndroidManifest.xml file and add this permission.

  • Although we have added the permission in our Manifest but if the device is running Android Marshmallow we need to ask the permission at run time. So for asking permission at run time I will create a button. So you create a simple button at your activity_main.xml. Or copy the following code and paste it to your activity_main.xml.

  • After this come to your and write the following code.

  • Thats it now you can run your application. But make sure the emulator you are using is running Android Marshmallow.
  • You can also download the source code from GitHub. Go to the link given below to get my source.

So thats all for this Android Marshmallow Permissions Example friends. I have explained all the codes with comments. But still if you are having any kind of confusion regarding this Android Marshmallow Permissions Example feel free to leave your comments. I will try to reply you all ASAP. Thank You 🙂

11 thoughts on “Android Marshmallow Permissions Example”

  1. this tuts is really helpfull for me but my question is that i develop an app which has sqlite database but when i run on marshmallow real device it crash so can u help me for that…thanks in advanced bro

  2. For camera and internet which code is to use as you have use the code for storage is
    private int STORAGE_PERMISSION_CODE = 23;

  3. Hi, sir
    i want to implment to show current location with address on textview with runtime permition(Android 6.0).please provide me tutorial its urgent.


Leave a Comment