Well, after all the explanations, we've reached the coding part, and this is where we will get our coding hands dirty. The following are key methods used for handling permissions:
Context.checkSelfPermission(): This checks whether your app has been granted a permission
Activity.requestPermission(): This requests a permission at runtime
Even if your app is not yet targeting Android Marshmallow, you should test your app and prepare to support it.
In the Android Marshmallow permissions model, your app must ask the user for individual permissions at runtime. There is limited compatibility support for legacy apps, and you should test your app and also test a version to make sure it's supported. ...