PERMISSIONS - Android Fundamentals

  Рет қаралды 47,125

Philipp Lackner

Philipp Lackner

Күн бұрын

In this video you will learn everything you need to know about permissions in Android.
⭐ Get certificates for your future job
⭐ Save countless hours of time
⭐ 100% money back guarantee for 30 days
⭐ Become a professional Android developer now:
pl-coding.com/...
Regular Android tutorials on my Instagram: / philipplackner_official
Checkout my GitHub: github.com/phi...

Пікірлер: 94
@s-w
@s-w 3 жыл бұрын
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 11 ай бұрын
please pin the above comment
@chasebrown8011
@chasebrown8011 11 ай бұрын
That's my intern!
@mayank_upadhyay_19
@mayank_upadhyay_19 2 ай бұрын
Hehe, it works now
@devprasad8767
@devprasad8767 Жыл бұрын
That permission dialog box is not showing for me
@charlesschen1292
@charlesschen1292 2 жыл бұрын
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 Жыл бұрын
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.
@nervous711
@nervous711 2 жыл бұрын
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
@b4ux1t3-tech
@b4ux1t3-tech 2 жыл бұрын
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 Жыл бұрын
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.
@redballtoy
@redballtoy Жыл бұрын
this code will only work for API
@PhilippLackner
@PhilippLackner Жыл бұрын
I do have up to date videos about permission handling
@SouravSharma-yp2ru
@SouravSharma-yp2ru Жыл бұрын
@@PhilippLackner yes pls do this
@fuadydheo3155
@fuadydheo3155 4 жыл бұрын
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 жыл бұрын
Thanks a lot, I will!
@gezafiqrullah5321
@gezafiqrullah5321 4 жыл бұрын
@@PhilippLackner Terima Kasih Pak Philip = Thank you Mr.Philip :)
@code_sorcerer123x
@code_sorcerer123x 2 ай бұрын
so confusing man!! :0 edit: i've watched it like 5 times .............now i understand :) thank you so much Pal
@basba_qal
@basba_qal 6 ай бұрын
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.
@rahulchaurasia5011
@rahulchaurasia5011 2 жыл бұрын
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 ??
@prolaymm
@prolaymm 10 ай бұрын
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.
@ohmegatech666
@ohmegatech666 Жыл бұрын
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
@betaaccount7450
@betaaccount7450 3 жыл бұрын
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 жыл бұрын
@@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())
@НиколайТурьев-ж9р
@НиколайТурьев-ж9р 4 жыл бұрын
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 !!!
@PhilippLackner
@PhilippLackner 4 жыл бұрын
Thanks for the feedback!!
@GeorgeTrialonis
@GeorgeTrialonis 2 жыл бұрын
No Permission prompt after I press the button. Can somebody help?
@rowenarrow
@rowenarrow 2 жыл бұрын
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 Жыл бұрын
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.
@KhinYadanarZaw-ll6cq
@KhinYadanarZaw-ll6cq 11 ай бұрын
Dexter is useful to manage multiple permissions , which is better ?
@hxrin3748
@hxrin3748 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
@asddsaasddsaasddsaasddsa
@asddsaasddsaasddsaasddsa 3 жыл бұрын
Probably you miss the "!" sign in if statements in "requestPermissions" function
@joeljaramillo7012
@joeljaramillo7012 3 жыл бұрын
I'm having the same problem
@陈大锤-q1s
@陈大锤-q1s 3 жыл бұрын
same problem
@sayangnyagulu160
@sayangnyagulu160 2 жыл бұрын
@@陈大锤-q1s me too
@devprasad8767
@devprasad8767 Жыл бұрын
me too
@LenaleiChanTing
@LenaleiChanTing 5 ай бұрын
my button part at the end isnt working
@Carisma2012
@Carisma2012 Жыл бұрын
my brain:Lord's mercy
@parthibanakt7090
@parthibanakt7090 2 жыл бұрын
How to analyze in Androidmanifest.xml file mentioned permissions are required for the application? It means how to find unwanted permissions ?
@footballCartoon91
@footballCartoon91 2 жыл бұрын
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?
@theai2020
@theai2020 3 жыл бұрын
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?
@emmanuelekowacquah155
@emmanuelekowacquah155 Жыл бұрын
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 Жыл бұрын
Okay, so I just read most of the permissions used are for android 10 and below.
@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?
@manishpingale6558
@manishpingale6558 3 жыл бұрын
Why there is '=" sign in front of that function? Thanks for AWESOME content
@hxrin3748
@hxrin3748 3 жыл бұрын
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 👍
@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
@shivtiwarii
@shivtiwarii 5 ай бұрын
very precise and complete at the same time, thank you Philipp
@gurarshdeepsingh5881
@gurarshdeepsingh5881 4 жыл бұрын
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 ??
@atharvaaswale7316
@atharvaaswale7316 3 жыл бұрын
What about internet permission?
@MrDari88
@MrDari88 3 жыл бұрын
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).
@TheImaginativeSachin
@TheImaginativeSachin Жыл бұрын
This was quite the video man. Almost didn't understand it but I did it!! I understand this subject at last.
@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,
@sergiaguilar1
@sergiaguilar1 3 жыл бұрын
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.
@footballCartoon91
@footballCartoon91 2 жыл бұрын
@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?
@timothyzhukov1159
@timothyzhukov1159 2 жыл бұрын
Awesome! 👍
@PhilippLackner
@PhilippLackner 2 жыл бұрын
Thanks! 👍
@matt-g-recovers
@matt-g-recovers 3 жыл бұрын
I gotta add, best Android permissions video currently.
@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.
@mehmetdurmaz636
@mehmetdurmaz636 2 жыл бұрын
You are King.
@iamfunny2155
@iamfunny2155 3 жыл бұрын
Pls how to open permission for data collector of code on Android studio
@titusnangi8586
@titusnangi8586 2 жыл бұрын
u always spot on with ur explanations...thank you Phillip
@rupendrakumar3061
@rupendrakumar3061 3 жыл бұрын
How to enable location services in WebView...?
@billmolloy2264
@billmolloy2264 11 ай бұрын
@jacobakoto9841
@jacobakoto9841 3 жыл бұрын
Will this code work for android 11?
@PJ-od9ev
@PJ-od9ev 2 жыл бұрын
You are amazing thanks a lot
@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 }
@the_sharma_amit
@the_sharma_amit 2 жыл бұрын
thanks bro.. from india
@denisk3852
@denisk3852 3 жыл бұрын
Do notifications need permissions?
@matt-g-recovers
@matt-g-recovers 3 жыл бұрын
Very cool Philipp!
@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 жыл бұрын
@@MCA_HimanshuSeth i can be your mentor
@arturrejment4016
@arturrejment4016 3 жыл бұрын
@@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 ?
@jishnunkrishnan5783
@jishnunkrishnan5783 3 жыл бұрын
Thank You
@kartikeyarawat1754
@kartikeyarawat1754 3 жыл бұрын
You're OG!
@briacroa6681
@briacroa6681 3 жыл бұрын
too complex. start with one permission.
@re_allyedge
@re_allyedge 4 жыл бұрын
I knew it, you are german. Me too :D
@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
@poultrydiseaseandtreatmentapp
@poultrydiseaseandtreatmentapp 10 ай бұрын
8:00 text is not that understandable
IMPLICIT INTENTS - Android Fundamentals
9:57
Philipp Lackner
Рет қаралды 27 М.
TOASTS AND CONTEXT - Android Fundamentals
16:51
Philipp Lackner
Рет қаралды 38 М.
Worst flight ever
00:55
Adam W
Рет қаралды 28 МЛН
Как подписать? 😂 #shorts
00:10
Денис Кукояка
Рет қаралды 8 МЛН
5 Kotlin Coroutine Secrets I Wish I Knew Earlier
24:23
Philipp Lackner
Рет қаралды 18 М.
RECYCLERVIEW - Android Fundamentals
24:58
Philipp Lackner
Рет қаралды 104 М.
ViewModels & Configuration Changes - Android Basics 2023
18:46
Philipp Lackner
Рет қаралды 121 М.
ALERT DIALOG - Android Fundamentals
18:47
Philipp Lackner
Рет қаралды 28 М.
How 1 Software Engineer Outperforms 138 - Lichess Case Study
22:28
Tom Delalande
Рет қаралды 58 М.
How to finally Git Good
9:43
Code Persist
Рет қаралды 20 М.
Test-Driven Development // Fun TDD Introduction with JavaScript
12:55
10 React Antipatterns to Avoid - Code This, Not That!
8:55
Fireship
Рет қаралды 749 М.
What is the Context? - Android Basics 2023
11:22
Philipp Lackner
Рет қаралды 58 М.
Worst flight ever
00:55
Adam W
Рет қаралды 28 МЛН