September 1, 2020

How to Request a Run Time Permission – Android Studio Tutorial

In this video we will learn, how to request a dangerous READ_EXTERNAL_STORAGE permission at run time, which is necessary since Android 6.0 (Marshmallow), whereas before this permission would be granted at the installation process. For this we will use the checkSelfPermission and requestPermissions methods and show a rationale to the user at the appropriate time with the shouldShowRequestPermissionRationale method.

Source code:

❗ Subscribe to the channel:

⏯ Watch more tutorials:

㊙ Help translating the videos:

💚 Support the content:

💬 Join the Discord chat:

🎧 Audiobooks and podcasts for programmers:

👶 How to get started with Android development:

📣 Follow Coding in Flow on social media:






Xem thêm bài viết khác:

Related Posts

hack password windows 7, 8, 10 bằng các câu lệnh command prompt

July 4, 2020

July 4, 2020 37

Thật ra cũng không phải là hack gì ghê gớm, đó chỉ là 1 câu lệnh đơn giản trong cmd,...

Hiếu WiFi Biến Modem cũ fpt thành trạm phát sóng wifi

July 1, 2020

July 1, 2020 42

Hướng dẫn cài đặt modem cũ fpt làm trạm phát sóng wifi phụ.mở rộng vùng phủ sóng wifi cho ngôi...

How To Repair Windows 7 And Fix Corrupt Files Urdu/Hindi

July 4, 2020

July 4, 2020 32

Subscribe Now: Hello Friends: Assalam-o-Alaikum kase hain Ap sub dost Umeed ha kharit se hoon ge dosto agr ap b...

How to ║ Restore Reset a ASUS Transformer Book Flip to Factory Settings ║ Windows 10

July 7, 2020

July 7, 2020 25

Buy the Asus Transformer Book Flip – This is a video on how to perform a factory restore on a...

How To Reset & Restore your Apple iPhone 7 – Factory Reset

July 8, 2020

July 8, 2020 47

Buy the Apple iPhone 7 – This is a video on how to perform a factory reset on a Apple...

Hướng dẫn cập nhật firmware loa JBL Pulse 2: fix lỗi đèn và mất kết nối

July 5, 2020

July 5, 2020 9

Hướng dẫn cập nhật firmware loa JBL Pulse 2: fix lỗi đèn và mất kết nối ▶ Mua loa JBL...

Hard reset iphone 6s/ 6s plus, SE, 6/ 6 / plus, 5s, 5c,5, 4s,4 (reset to factory settings)

July 4, 2020

July 4, 2020 32

How to hard reset to clear all your information from iPhone. This method of resetting the phone is used when...

How To Fix Windows Startup Repair cannot repair this computer automatically

July 6, 2020

July 6, 2020 27

How To Fix Windows Startup Repair cannot repair this computer automatically 1:00 Command Prompt 1:17 bootrec /fixmbr 1:30 bootrec /fixboot...

Hard Reset bằng phím cứng điện thoại LG – How to Hard Reset LG Mobile

July 8, 2020

July 8, 2020 2

How to Hard Reset LG Mobile Tracfone 3 phương pháp Hard / factory reset LG Điện thoại Chúng ta đều...

Bài 22: Công cụ Pencil và Color Replacement | Làm Chủ Photoshop CC 2018

July 4, 2020

July 4, 2020 21


How To Repair Windows 10

July 9, 2020

July 9, 2020 29

How To Repair Windows 10 If your having trouble with Windows 10 and you want to try repairing it before...

How to Request Multiple Permission in Android Studio | RequestPermission | Android Coding

July 2, 2020

July 2, 2020 7

Request Permission Tutorial : In This Video, You Will Learn How to Request Multiple Permission in Android Studio. All File...

Hướng dẫn Reset Window 10 về mặc định như lúc mới cài windows | namloan ✅

July 5, 2020

July 5, 2020 34

✅ Bạn đã sử dụng Windows 10 được một thời gian và nhận thấy máy tính của bạn không hoạt...

How to Reset TP-Link WiFi Router Forgotten Password

July 5, 2020

July 5, 2020 20

Hi Everyone 🙂 In this video video will teach of How to simply Reset your TP-Link WiFi Router Forgotten Password/Settings....

Remove Quick Access Icon from Windows 10 File Explorer

July 3, 2020

July 3, 2020 6

How To Remove Quick Access From Windows 10 Navigation Pane Remove Background from Images in 5 Seconds Without a Single...

  • private void isPermissionGranted(){

    if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE)==PackageManager.PERMISSION_GRANTED){

    Toast.makeText(getContext(), "PERMISSION GRANTED", Toast.LENGTH_SHORT).show();

    } else {




    void requestStoragePermission(){


    new AlertDialog.Builder(getContext())

    .setTitle("Permission needed")

    .setMessage("This permission is needed because of")

    .setPositiveButton("OK", new DialogInterface.OnClickListener() {


    public void onClick(DialogInterface dialogInterface, int i) {

    requestPermissions(new String[] {Manifest.permission.READ_EXTERNAL_STORAGE}, PERMISSIONS_CODE);



    .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {


    public void onClick(DialogInterface dialogInterface, int i) {




    } else {

    requestPermissions(new String[] {Manifest.permission.READ_EXTERNAL_STORAGE}, PERMISSIONS_CODE);



  • Can I show alert dialog here,after user click on don't ask again and deny also, share the code please, it would be very helpful to me

  • Works on Android studio but not in real device ?
    And can you please tell why am i not getting JSON data from web in my real device but I get it on Android studio?

  • /storage/emulated/0/Download/2020-03-30 19:32:03.pdf: open failed: EACCES (Permission denied)
    What this error means and how to solve it.

  • Would you please do a video on how to delete a sent SMS from inside your app, also how to grant permissions for apps that have multiple activities which require permissions. Thanks in advance….great video!

  • does every runtime, X permission will be prompted to the user?, or just once?, i mean if user grant X permission, in the next user open the app, will X permission is requested again, and again and again ??

  • I'm unable to import I just have app/graphics/os.
    Does anyone has an idea?

  • Bro, when I click the button I am getting permission denied and after that, the accept/deny popup appears…..
    can you please say what mistake has happened here??

  • phisitja เล่นดนตรีสนุกๆ พิสิฏฐ์ ศรีวิลาศ ฟลุ๊ก fluke says:


  • it doesn't work when i try typing in the context part it turns red and wont compile and send my app to my samsung galaxy j3 aura for testing and i am using android studio now

    i tried the one on google's android development website too and it did not work either but i knew it wasn't going to because none of their code works


  • I wish I had your knowledge.. I will ask a question that I hope is not too nooby as I am a beginner: Why do you pass MainActivity.this as context on some methods and just this on others?
    Ok sorry two more questions if I may…
    Do you have any tutorial recommendations to understand the whole Context concept?
    Are you German or from any German-speaking country?
    Love your videos btw.. I'll hopefully pass my Android exam thanks to you.
    In case third question is a yes… Danke schön und viele grüße aus Singapore!

  • Great tut. For anyone interested in going one step further and detect if Don't ask again was pressed I have found very interesting and clear the following Medium article: just search in Google 'Method to detect if user has selected “Don’t Ask Again” while requesting for permission'

  • Thanks man. Very clear explanation. I'm currently working on my Android App Exams and this video was very helpfull. (we are allowed to use any outside sources) Now all i have to do is add an Intent to the same button.

    Btw it might be an idea to add the code in the description.

  • my activity.main doesn't opening like that, when i open activity.main it will open preview what happenning?? help

    note* I am learning from today

Leave a Reply

Your email address will not be published. Required fields are marked *