January 18, 2021

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:





Nguồn: https://belahanajima.com/

Xem thêm bài viết khác: https://belahanajima.com/cong-nghe/

Related Posts

Nokia Lumia 520 hard reset

July 8, 2020

July 8, 2020 50

In this Tutorial I will show you how to hard reset Nokia Lumia 520 (Windows 8 mobile).You can use this...

Cara reset epson L130, resetter epson L310, adjusment epson L130

June 29, 2020

June 29, 2020 14

Cara reset epson L130, resetter epson l310, adjusment epson l130 Buy the Adjustment Tool / Adjusment Tool / Resetter Saya...

Winrar password remover tool how to Remove zip/rar file password in hindi

July 1, 2020

July 1, 2020 20

Zip/winrar password remover. how to remove winrar file password. is video me apko rar file password kaise crack karte hai...

Hướng dẫn sử dụng IDM Trial Reset | crack IDM dùng thử bản quyền Internet Download Manager vĩnh viễn

June 30, 2020

June 30, 2020 16

Video hướng dẫn thực hiện reset trial (khôi phục thời hạn dùng thử) phần mềm Internet Download Manager (IDM). =============================...

Đổi Mật Khẩu WiFi Mạng VNPT Bằng IP Quản Trị Không Cần Pass Modem

July 9, 2020

July 9, 2020 32

Đổi mật khẩu wifi mạng vnpt bằng ip quản trị không cần password có thể đổi mật khẩu wifi bằng...

How to Reset a Macbook Air to Factory Settings

July 3, 2020

July 3, 2020 43

Get it here… As an Amazon Associate I earn from qualifying purchases. Need a quick loan? Travel deals on Expedia…...

Repair Windows 10 using Automatic Repair

June 28, 2020

June 28, 2020 21

Repair Windows 10 using Automatic Repair You can also try Windows Boot Genius ( to repair Windows 10/8.1/8/7/XP/Vista to fix...

How To Reset Samsung Galaxy J7 Prime – Hard Reset

July 8, 2020

July 8, 2020 49

This is a video on how to perform both methods of a hard reset on a 2017 Samsung Galaxy J7...

iPhone 5 hard reset réplica

July 8, 2020

July 8, 2020 20

Fala galera, vídeo mostrando pra vocês como realizar o hard reset na réplica do iPhone 5. Como destravar, como formatar,...

Hướng dẫn cách cài đặt win 10 bằng usb, cài lại win 10 đơn giản ai cũng làm được

July 6, 2020

July 6, 2020 20

Cài win 10 bằng usb không khó, video hướng dẫn toàn bộ quá trình cài đặt win 10 cho mọi...

IDM Trial Reset and Registration Full Version For Free

July 7, 2020

July 7, 2020 5

Hello Every One I Welcome, In This Video I will Show You How To Reset IDM Free for 30 days...

Hack system32 để mở cmd trên màn hình login

July 9, 2020

July 9, 2020 13

Hack system32 để mở cmd ngoài màn hình login trên mọi windows(7,8,8 1,10) Chắc các bạn thắc mắc việc mở...

Excel's Find and Replace (surprising features)

July 6, 2020

July 6, 2020 39

Check the Excel Essentials Course: Use Excel’s Find and Replace feature to not only find and select all cells, but...

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 reset identity to 1 in SQL server | Difference b/w Truncate and Delete | Database Sql server

July 4, 2020

July 4, 2020 1

Microsoft SQL Server’s identity column generates sequential values for new records using a seed value. The term seed refers to...

  • 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 android.support.v4.content.ContextCompat. I just have android.support.v4. 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 *