Stuck in blocks for permission

Dear member,
I try to set a custom ringtone through my app. Pic

1st time its taking user to app settings . But ringtone is not setting
Ok 2nd time its giving runtime erroer shown in image.

I am stuck
Pls help me

Because first you have to ask permission then when permission is granted do other process

Can you explain by code. I want set ringtone permission . Is it dangerous permission or normal?

According to this screenshot:

You need these permissions:


Maybe you need this too if app is running on API 23 (Android 6) or above:


1 Like

My app can be run on api >23 , api <23.
I have a button which sets custom rigtone.
What is the the allowed way to ask permission and handle user behaviour.