PERMISSIONS - Android Fundamentals

แชร์
ฝัง

ความคิดเห็น • 92

  • @s-w
    @s-w 3 ปีที่แล้ว +56

    May 2021 update: For those having trouble with location permissions on API 30 or higher, here is a solution.
    Within requestPermissions(), on the third if() statement regarding background permissions, change the code to:
    if(!hasLocationBackgroundPermission() && hasLocationForegroundPermission())
    In this case, the button must be clicked twice to request background location permissions. (I'm sure there's a more correct way to implement this, but this is an easy way to correct the problem in this case).
    To learn more why this works, look up "Request location permissions" in the Android Developer documentation. There is a statement that says requesting foreground and background permissions at the same time will be ignored. Furthermore, background permissions will not be granted unless foreground permissions were previously granted.

    • @kartikagarwal1795
      @kartikagarwal1795 3 ปีที่แล้ว

      Hello
      There is one more way to done it using single click only
      just add this code again in onRequestPermissionsResult
      permissionToRequest.clear()
      if (hasForegroundPermission() && !hasBackgroundPermission()) {
      permissionToRequest.add(Manifest.permission.ACCESS_BACKGROUND_LOCATION)
      }
      if (permissionToRequest.isNotEmpty()) {
      ActivityCompat.requestPermissions(this, permissionToRequest.toTypedArray(), 0)
      }

    • @younesboulghobra
      @younesboulghobra ปีที่แล้ว

      Thank you for the explanation , it was really helpful .

    • @billmolloy2264
      @billmolloy2264 8 หลายเดือนก่อน

      please pin the above comment

    • @chasebrown8011
      @chasebrown8011 8 หลายเดือนก่อน

      That's my intern!

  • @user-os8zr3sd2m
    @user-os8zr3sd2m 3 ปีที่แล้ว +2

    Very very cool. Very local, as if everything was gradually assembled, the first I see this. You are younger !!! Good luck, thanks for the content !!!

  • @TheImaginativeSachin
    @TheImaginativeSachin ปีที่แล้ว

    This was quite the video man. Almost didn't understand it but I did it!! I understand this subject at last.

  • @b4ux1t3-tech
    @b4ux1t3-tech 2 ปีที่แล้ว +9

    Hey Philipp, I love your videos.
    I just wanted to point out that this workflow is (sorta?) deprecated according to the documentation. I'd love to see an updated video covering the new paradigm. I've been trying to wrap my head around it, and was kind of disappointed you don't have a more recent video on this, since you're who I turn to to clarify stuff like this!
    In any case, keep up the great work. Loving the newer Compose content.

    • @isown8131
      @isown8131 2 ปีที่แล้ว

      Hey , why is it sorta deprecated? Are you referring to the fact that he is not using shouldShowRequestPermissionRatinonale()? Is the rest of his code good for use?

    • @b4ux1t3-tech
      @b4ux1t3-tech 2 ปีที่แล้ว

      @@isown8131 It's more that there are more modern APIs to manage permissions. For the most part, it's still a great video. I don't remember the specific thing I had problems with.

    • @JoeSteele
      @JoeSteele 10 หลายเดือนก่อน

      I would also love this. I just ran into the message `getSerializedExtra` is deprecated and the alternative (passing the class as a param) is also not working.

  • @mattgraves3709
    @mattgraves3709 3 ปีที่แล้ว

    I gotta add, best Android permissions video currently.

  • @titusnangi8586
    @titusnangi8586 2 ปีที่แล้ว

    u always spot on with ur explanations...thank you Phillip

  • @fuadydheo3155
    @fuadydheo3155 4 ปีที่แล้ว +7

    Its awesome dude, keeping up make more videos, because its very useful for us to learning fundamental to expert android, love from Indonesia

    • @PhilippLackner
      @PhilippLackner  4 ปีที่แล้ว +3

      Thanks a lot, I will!

    • @gezafiqrullah5321
      @gezafiqrullah5321 3 ปีที่แล้ว

      @@PhilippLackner Terima Kasih Pak Philip = Thank you Mr.Philip :)

  • @shivtiwarii
    @shivtiwarii 3 หลายเดือนก่อน

    very precise and complete at the same time, thank you Philipp

  • @mattgraves3709
    @mattgraves3709 3 ปีที่แล้ว

    Very cool Philipp!

  • @nervous711
    @nervous711 2 ปีที่แล้ว +5

    Hi, Philipp, thanks again for your awesome content!
    Can I ask why at 11:10 you specified that in this case "Make sure you use ActivityContext instead of ApplicationContext"?
    Still confused about when to use ActivityContext or ApplicationContext

  • @timothyzhukov1159
    @timothyzhukov1159 2 ปีที่แล้ว +1

    Awesome! 👍

  • @the_sharma_amit
    @the_sharma_amit 2 ปีที่แล้ว

    thanks bro.. from india

  • @PJ-od9ev
    @PJ-od9ev 2 ปีที่แล้ว

    You are amazing thanks a lot

  • @devprasad8767
    @devprasad8767 ปีที่แล้ว +3

    That permission dialog box is not showing for me

  • @dharmeshbasapati4497
    @dharmeshbasapati4497 2 ปีที่แล้ว

    Hi Philipp,
    Great video once again.
    Could you please create one more video showing how to use new Activity Contract API for requesting permissions and handling denying and rejections.
    Thanks in advance,

  • @mehmetdurmaz636
    @mehmetdurmaz636 2 ปีที่แล้ว

    You are King.

  • @jishnunkrishnan5783
    @jishnunkrishnan5783 3 ปีที่แล้ว

    Thank You

  • @emmanuelekowacquah155
    @emmanuelekowacquah155 9 หลายเดือนก่อน

    I want to say a big thanks Philipp. Your videos have a very easy-to-grasp logic and have been a big help with my studies. I would like to request if you could make an update on the permissions video. When I follow the session after launching the app, it does not show the request to accept permissions.

    • @emmanuelekowacquah155
      @emmanuelekowacquah155 9 หลายเดือนก่อน

      Okay, so I just read most of the permissions used are for android 10 and below.

  • @charlesschen1292
    @charlesschen1292 2 ปีที่แล้ว +5

    Hi phillip i could really understand about every video you've put into work. But there's one that still confused me.
    Why we use hasWriteExternalStorage with "function (private fun)" instead of "variable (var/val)"
    Please help if someone could give an explanation. Thankyou

    • @broma3974
      @broma3974 ปีที่แล้ว +1

      I think it might be because a function definitively gets called when you invoke it (and only then assigns a value to the expression you mentioned) whereas a variable gets assigned wherever in the code you write it. You can't "call" a variable to recheck whether the value of that expression has changed, you'd just have to rewrite the variable or expression all over again any time you'd want to recheck if it has changed.
      That's my understanding of it anyway. I could be totally off the mark.

  • @theai06
    @theai06 2 ปีที่แล้ว

    what is the difference between dexter permissions and android default permissions is dexter more powerfull then the default android permissions and will this code run with android 11 as well?

  • @rahulchaurasia5011
    @rahulchaurasia5011 2 ปีที่แล้ว +1

    Nice Video Sir, How to handle when user again click "deny and Don't ask again" . I prefer open device permission setting on the basis of result of onRequestPermissionResult. Please guide ??

  • @astaghfirullahalzimastaghf3648
    @astaghfirullahalzimastaghf3648 ปีที่แล้ว

    suddenly i am thinking if i can convert manifest file into JSON object then maybe i can do something with it using javascript..
    does xml code being compiled/ parsed into java byte code?
    is there a way of asking permission using kotlin (programmatically) and not xml
    is xml secure?

  • @kartikeyarawat1754
    @kartikeyarawat1754 2 ปีที่แล้ว

    You're OG!

  • @parthibanakt7090
    @parthibanakt7090 2 ปีที่แล้ว

    How to analyze in Androidmanifest.xml file mentioned permissions are required for the application? It means how to find unwanted permissions ?

  • @gurarshdeepsingh5881
    @gurarshdeepsingh5881 3 ปีที่แล้ว

    Here in HAS functions we use = sign ...not curly brackets ... I noticed If I put brackets and specify type explicit then == GrantPermission..... not works ...why ??

  • @KhinYadanarZaw-ll6cq
    @KhinYadanarZaw-ll6cq 8 หลายเดือนก่อน

    Dexter is useful to manage multiple permissions , which is better ?

  • @iamfunny2155
    @iamfunny2155 3 ปีที่แล้ว

    Pls how to open permission for data collector of code on Android studio

  • @redballtoy
    @redballtoy ปีที่แล้ว +1

    this code will only work for API

    • @PhilippLackner
      @PhilippLackner  ปีที่แล้ว

      I do have up to date videos about permission handling

    • @SouravSharma-yp2ru
      @SouravSharma-yp2ru 10 หลายเดือนก่อน

      @@PhilippLackner yes pls do this

  • @lara-kp7lp
    @lara-kp7lp 2 ปีที่แล้ว

    Whenever i create app with internet permission it only works when installed from android studio.Not as apk why so?

  • @prolaymm
    @prolaymm 7 หลายเดือนก่อน

    Sir i visited your site to buy android course unfortunatly i can't effort. I'm working as a Mobile App developer only for 120$ per month. Sir if you have any scholor program please let me know. Btw thank you for you high quality tutorials.

  • @hxrin3748
    @hxrin3748 3 ปีที่แล้ว +3

    Hi Phillip, thanks a lot for your tutorials, they are great. I am having problem with this part though, I've done everything you did but Im not getting the Permission prompt after clicking a button, nothing happens. I am using API 30 (Pixel 2) - could that be a problem? Thanks a lot

  • @denisk3852
    @denisk3852 3 ปีที่แล้ว

    Do notifications need permissions?

  • @betaaccount7450
    @betaaccount7450 3 ปีที่แล้ว +2

    It is not working on A11 like the pop up for asking for permission is not showing up at all on clicking button, the log says button was clicked but nothing regarding the permission
    while the app works properly on A10 or below

    • @51bpegasi
      @51bpegasi 3 ปีที่แล้ว

      having the same problem here, unfortunately

    • @betaaccount7450
      @betaaccount7450 3 ปีที่แล้ว +1

      @@51bpegasi actually do one thing ask for foreground location only
      Asking both at same time cause pop up to get rejected by system on A11

    • @51bpegasi
      @51bpegasi 3 ปีที่แล้ว

      @@betaaccount7450 you are right! thanks!
      also tried A C's suggestion, it works too: if(!hasLocationBackgroundPermission() && hasLocationForegroundPermission())

  • @rupendrakumar3061
    @rupendrakumar3061 3 ปีที่แล้ว

    How to enable location services in WebView...?

  • @manishpingale6558
    @manishpingale6558 3 ปีที่แล้ว +1

    Why there is '=" sign in front of that function? Thanks for AWESOME content

    • @hxrin3748
      @hxrin3748 3 ปีที่แล้ว +4

      hey, the = is there because 'hasWriteExternalStoragePermission' returns a single Int value and because of that, it can be written like this. This is how single expression functions are described in documentation:
      Single-expression functions
      When a function returns a single expression, the curly braces can be omitted and the body is specified after a = symbol:
      example: fun double(x: Int): Int = x * 2

    • @manishpingale6558
      @manishpingale6558 3 ปีที่แล้ว

      @@hxrin3748 oh oh thanks got it 👍

  • @astaghfirullahalzimastaghf3648
    @astaghfirullahalzimastaghf3648 ปีที่แล้ว

    @8:02
    Bro how come you can compare Manifest.permission to PackageManager.PERMISSION_GRANTED??
    is PackageManager an abstract class
    and so does it need to be implemented or inherited first?

    • @mayor3367
      @mayor3367 ปีที่แล้ว

      Hey, I hope you already have the answer. If not, PackageManager is an abstract class (as you had surmised) but what we are comparing isn't PackageManager itself but a public static property within PackageManager itself. The property is an integer type and I suppose the checkSelfPermission method returns an integer, which makes both the PackageManager.PERMISSION_GRANTED and the checkSelfPermission comparable to each other. If you have never done Java, think of a static property like a companion object which you can use without actually creating an object of a particular class in Kotlin.

  • @Hyfh2
    @Hyfh2 3 ปีที่แล้ว

    why not able to android R this permission?

  • @MCA_HimanshuSeth
    @MCA_HimanshuSeth 4 ปีที่แล้ว

    Very nice explanation , dear sir I have two questions
    1. In my mobile this code only asks for COARSE_LOCATION and EXTERNAL_STORAGE but not for BACKGROUND_LOCATION
    I don't know why ???
    2. When I accept those permission my GPS location doesn't on , and also internet connection doesn't ON, Why ?? I have accepted those permission .

    • @PhilippLackner
      @PhilippLackner  4 ปีที่แล้ว

      Background location is only for API 29 (android Q)
      I don't get your second question

    • @MCA_HimanshuSeth
      @MCA_HimanshuSeth 4 ปีที่แล้ว

      @@PhilippLackner sir I am from Varanasi , India , and I am a beginner but there is no one to help me , can I have your contact details so that I can ask you questions
      My gmail id is - himanshuseth.in@gmail.com
      Sir plz send me your email id so that I can ask questions plzzz..
      Sir plz I am very interested in android development but no teacher I have

    • @krzysztoffarys7189
      @krzysztoffarys7189 3 ปีที่แล้ว +1

      @@MCA_HimanshuSeth i can be your mentor

    • @arturrejment4016
      @arturrejment4016 3 ปีที่แล้ว +1

      @@MCA_HimanshuSeth hello my Friend. Im hindi too :) Do not worry about my European nickname, it's just a simple trick so the youtubers answer my questions more often. @krzysztof is my mentor since 2019 and thanks to Him i recently got promoted from Young Junior Account Brand Manager to Young Junior Executive Account Brand Manager!! :) I am so grateful to this bright man!

    • @MCA_HimanshuSeth
      @MCA_HimanshuSeth 3 ปีที่แล้ว

      @@krzysztoffarys7189 how can I contact you ?

  • @jacobakoto9841
    @jacobakoto9841 3 ปีที่แล้ว

    Will this code work for android 11?

  • @sergiaguilar1
    @sergiaguilar1 2 ปีที่แล้ว +2

    If your app targets Android 10 (API level 29) or higher, remove the ACCESS_BACKGROUND_LOCATION permission from your app's manifest. When you remove this permission, all-the-time access to location isn't an option for the app on devices that run Android 10.

  • @gutic4824
    @gutic4824 4 ปีที่แล้ว

    Nice video as always!!! I have a question with this line:
    if(permissionsToRequest.isNotEmpty()) {
    ActivityCompat.requestPermissions(this,permissionsToRequest.toTypedArray(),0)
    }
    I dont understand well why you use ActivityCompat.requestPermissions(this,permissionsToRequest.toTypedArray(),0)
    Thanks a lot for such amazing videos

    • @ericgoto2459
      @ericgoto2459 4 ปีที่แล้ว

      he explains it in the video

  • @user-pc9hc3tu9p
    @user-pc9hc3tu9p 2 หลายเดือนก่อน

    my button part at the end isnt working

  • @atharvaaswale7316
    @atharvaaswale7316 3 ปีที่แล้ว +1

    What about internet permission?

    • @MrDari88
      @MrDari88 3 ปีที่แล้ว +1

      The Internet permission is not considered as a dangerous permission by Android. As such, you only need to declare it within your manifest file (it does not need user acceptance since it does not compromise your privacy).

  • @GeorgeTrialonis
    @GeorgeTrialonis 2 ปีที่แล้ว +1

    No Permission prompt after I press the button. Can somebody help?

    • @rowenarrow
      @rowenarrow 2 ปีที่แล้ว +1

      Same here, but I believe that is due to API change. I understand the concepts, just need to practice what the documentation states. So I plan on recreating this after I finish the complete playlist.

    • @devprasad8767
      @devprasad8767 ปีที่แล้ว

      @@rowenarrow did you figure out?

    • @broma3974
      @broma3974 ปีที่แล้ว +2

      If the API your phone or emulator uses is past 29 this tutorial is slightly outdated. I think when it comes to requesting location you can still use almost the exact same format the video uses but you can't request background location and foreground (course or fine) location at the same time like he does. You need to first request foreground location and once that has been accepted you can seperately request background location. Try commenting out the request for background location alltogether and this video should still work and will get you a permission prompt asking if you'll accept the app using foreground location.

  • @billmolloy2264
    @billmolloy2264 8 หลายเดือนก่อน

  • @Carisma2012
    @Carisma2012 ปีที่แล้ว

    my brain:Lord's mercy

  • @ohmegatech666
    @ohmegatech666 11 หลายเดือนก่อน

    OK but this doesn't explain at all when you should request the permissions, what to do once you've gotten them, when yo might need to request them again or anything about how permissions work in the context of a full Android application

  • @re_allyedge
    @re_allyedge 3 ปีที่แล้ว +1

    I knew it, you are german. Me too :D

  • @poultrydiseaseandtreatmentapp
    @poultrydiseaseandtreatmentapp 7 หลายเดือนก่อน

    8:00 text is not that understandable

  • @briacroa6681
    @briacroa6681 2 ปีที่แล้ว +1

    too complex. start with one permission.

  • @basba_qal
    @basba_qal 3 หลายเดือนก่อน

    Android studio 2023 SUCKS big time.
    Slow, hogs all of your memory, task manager can't end process, downloads stuff and packages every time an app is being debugged andvryn, indexing tajes forever to finish, gradle jeeps downloading unneeded 💩💩💩packages
    Device manager can't launch virtual devicevor hookbup tova real one, and if successful the device would horribly display your layout.

  • @Hamza-Shreef
    @Hamza-Shreef ปีที่แล้ว

    7:40
    what do you think if i create a single function and just pass it the permission you want to check and it should return a boolean value like this:
    private fun hasPermission(permission:String):Boolean {
    return ContextCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_GRANTED
    }

  • @gilsonjuniorpro
    @gilsonjuniorpro ปีที่แล้ว

    Hey man, need some help, do you know why is this permission?
    I tried to remove it and run the app, did several tests and apparently nothing changed, but I am trying to understand why this permission is needed, thank you

  • @rishabjain2634
    @rishabjain2634 ปีที่แล้ว

    can some one help me out after the activtyCompat(....)==packageManager.PERMISSION_GRANTED for me the PERMISSION_GRANTED IS NOT SHOWING??

    • @broma3974
      @broma3974 ปีที่แล้ว

      "PackageManager" not "packageManager". That's probably your mistake as well as anyone else who has the same problem.