Location | Request Location Updates | Location SettingsClient | FusedLocationProviderClient

  Рет қаралды 22,251

Mafia Codes

Mafia Codes

4 жыл бұрын

In this video you will learn - how to use the Settings Client to check which settings are enabled, and present the #Location Settings dialog for the user to update their settings with a single tap.
Then we will learn - how to request regular updates (#locationupdates) about a device's #location using the #requestLocationUpdates() method in the fused location provider.
We will be using the google’s #LocationRequest and #SettingsClient for changing location settings.
We will also be using the google’s #FusedLocationProviderClient for getting the location updates.
⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. I've been using Kite for 6 months and I love it! www.kite.com/get-kite/?...
FREE $100 credit @Digital Ocean: m.do.co/c/3208f08b3324
Patreon: / trulymittal
Subscribe: kzfaq.info...
#Tutorial (#Github): github.com/trulymittal/Locati...
Dependency: developers.google.com/android...
Location Overview: developer.android.com/trainin...
---------------
More useful videos
---------------
RecyclerView: • Recycler View with com...
ViewModel: • View Model | Live Data...
NavigationComponent: • Navigation Component |...
WorkManager: • Work Manager | Android...
Retrofit: • RETROFIT Tutorial (v 2...
CollapsingToolbar Layout: • Collapsing Toolbar Lay...
BottomNavigation View: • Bottom Navigation View...
KeyframeAnimations: • Keyframe Animations wi...
NightMode: • Night Mode | Dark Mode...
ButterKnife: • Butter Knife | Field a...
SplashScreen: • Splash screen | Launch...
Singletons: • Singletons | What When...
Pull to Refresh in RecyclerView: • Pull to Refresh in Rec...
On item click using Interface in RecyclerView: • RecyclerView item Clic...
Swipe gestures in Recycler View: • Swipe gestures in Recy...
Drag and drop Reorder in Recycler View: • Drag and drop Reorder ...
Filter using SearchView in RecyclerView: • Filter RecyclerView us...
MultiView RecyclerView: • Multi view RecyclerVie...
---------------
Other useful Playlists
---------------
Android: • Android
Firebase: • Firebase | Build a Not...
RestAPI (NodeJS and MongoDB): • REST API using NodeJS ...
Docker: • Docker
MongoDB: • Learn MongoDB in 50 mi...
Html/Css/Js: • HTML / CSS / JS
Challenges: • Challenges
---------------
What I use
---------------
Mouse: amzn.to/2O9RJtu
Keyboard: amzn.to/2qxajCU
Keyboard 2: amzn.to/2XDWH4X
Monitor: amzn.to/2pDg7dH
Processor: amzn.to/347WWIb
RAM: amzn.to/2QEkUqw
Graphics: amzn.to/33aBrF4
Microphone: amzn.to/2DabdI9
#yoursTRULY #tutorial #howto #android

Пікірлер: 95
@rhupin5276
@rhupin5276 2 жыл бұрын
Thank you sensei. This video deserves a like!
@_avani_official3782
@_avani_official3782 2 жыл бұрын
Thank you for this !!!
@dkqjd920wj
@dkqjd920wj 4 жыл бұрын
This tutorial is very helpful, thank you a lot.
@mafiacodes
@mafiacodes 4 жыл бұрын
Subscribe like share
@arpitanand6534
@arpitanand6534 3 жыл бұрын
Thankyou so much! I finally completed the code!!!
@mafiacodes
@mafiacodes 3 жыл бұрын
Great!
@sahiltyagi4994
@sahiltyagi4994 3 жыл бұрын
worked like a charm
@rafaioshi
@rafaioshi 3 жыл бұрын
Very good video!
@theophilus494
@theophilus494 3 жыл бұрын
thank you
@programmertony6061
@programmertony6061 2 жыл бұрын
So much helpful Sir. Love from Bangladesh.
@mafiacodes
@mafiacodes 2 жыл бұрын
So nice of you
@satyamverma2110
@satyamverma2110 3 жыл бұрын
Thank you soo much bro !!!
@mafiacodes
@mafiacodes 3 жыл бұрын
You're welcome!
@mehowildsouza2241
@mehowildsouza2241 3 жыл бұрын
Hey would this code work in which on the click of a button we store the users x and y cordinates .... Then user closes the app later he again runs the same code in a different place will it show the updated x and y cordinates
@mubeenrizvi256
@mubeenrizvi256 4 жыл бұрын
thanks man you are a saviour, my fyp is almost completed thanks to you, i just have one question that i want to to do this in background as well when the app is closed, can you guide me about this or do you have a tutorial for this?
@mafiacodes
@mafiacodes 4 жыл бұрын
use work manager, its meant for that only. and I have a couple of videos about work manager, you can watch them
@mohammedmasiullah5201
@mohammedmasiullah5201 4 жыл бұрын
Bro I am really grateful to you for creating such amazing video. Can you please make a video where I can get the location in the back ground using services and then sending the location to the activity
@mafiacodes
@mafiacodes 4 жыл бұрын
For that u should use work manager
@geekyrider007
@geekyrider007 4 жыл бұрын
In my app everytime user turns off the location then the location updates are taking too long to respond.Is there any solution Need Help
@pradeepkumarreddykondreddy7048
@pradeepkumarreddykondreddy7048 4 жыл бұрын
Can we call the LocationSettingsRequest from a foreground service ?? Looks like startResolutionForResult(Activity, int) method takes activity as the first parameter. I'm requesting for location updates from a foreground service.
@mafiacodes
@mafiacodes 4 жыл бұрын
Yes u can I guess
@tonnie7079
@tonnie7079 4 жыл бұрын
Hello Buddy, I liked your presentation - very informative. Please if you don't mind which font are you using, it is just out of this world!!
@mafiacodes
@mafiacodes 4 жыл бұрын
Thanks, subscribe like share Font: Operator Mono
@tonnie7079
@tonnie7079 4 жыл бұрын
Thanks @yoursTruly for a swift response, I have subscribed n shared. Sorry, I can see Operator Mono on my AS. I also want the exact colors that you are using. Please help me
@mafiacodes
@mafiacodes 4 жыл бұрын
Using google developers theme
@piyushsharma7795
@piyushsharma7795 2 жыл бұрын
Can you please tell me what to do when lastKnownLocation gives null location means how can I set a location programmatically?
@CamellCamells
@CamellCamells 3 жыл бұрын
Another amaizing video, thank you very much! But i am wondering, if the my app is using location in every activity, i should put that code in every activity, right? Thank you again!
@mafiacodes
@mafiacodes 3 жыл бұрын
Not necessarily use one activity and then use fragments and listen for location updates....
@sonnguyenhoang5657
@sonnguyenhoang5657 3 жыл бұрын
Can you show me how to add location to the list anytime it updates. Thank you.
@devenwarang3687
@devenwarang3687 3 жыл бұрын
You are getting location updates on the main UI thread. So is it possible that the UI Thread may hang and freeze the screen in some cases while trying to retrieve current location updates?
@mafiacodes
@mafiacodes 3 жыл бұрын
Location updates are being called using a task, which is asynchronous, so don’t worry
@devenwarang3687
@devenwarang3687 3 жыл бұрын
@@mafiacodes so while reverse geocoding, it may hang the UI? btw thanks..
@abhisheksatpute1052
@abhisheksatpute1052 3 жыл бұрын
Sir, in onLocationResult method, can we use toast instead of Log. d
@abhisheksatpute1052
@abhisheksatpute1052 3 жыл бұрын
Also how we can store and update location on real time database
@akbarnotoponcobimantoro3865
@akbarnotoponcobimantoro3865 3 жыл бұрын
how to integrate with hms?
@haideryt5617
@haideryt5617 3 жыл бұрын
What if I wanted to request a location only once?? I do not want to request locations again and again I just want the location of the client once he opens the activity
@mafiacodes
@mafiacodes 3 жыл бұрын
This wud help you kzfaq.info/get/bejne/qLSJlKh30Zyqnac.html
@pradeepkumarreddykondreddy7048
@pradeepkumarreddykondreddy7048 4 жыл бұрын
In a foreground service, i'm using FusedLocationProviderClient to request for location updates. I'm using foreground service because, i want location updates even when the app is closed. so far so good. it is working. But the problem is, if the gps is turned off then i'm not getting the onLocationResult() call back. How to handle this problem ?? Before starting the service, location was on and i got a couple of callbacks in onLocationResult() method. After sometime, user turned off the gps, after that i'm not getting the onLocationResult() call back. Any idea how to deal with this problem ??
@mubeenrizvi256
@mubeenrizvi256 4 жыл бұрын
can you guide, how to do this in a foreground service?
@mafiacodes
@mafiacodes 4 жыл бұрын
Well u can use location settings and check them in case location settings not satisfied send a notification to user to enable the services
@AbdulSamad-yu1zn
@AbdulSamad-yu1zn 4 жыл бұрын
I Liked Your Video.. Apreciated.. But i hace a question..! Its returning location in longitude and latitude values. make a tutorial.. that how to get real world location from these valuea
@mafiacodes
@mafiacodes 4 жыл бұрын
Coming in next couple of videos
@user-kl5ur9ee8j
@user-kl5ur9ee8j 2 жыл бұрын
how to send this updated location repeatedly to the firebase firestore and then what is the method to retrieve updated location from firebase. Assume i have two different version of application where first one sends the location and other retrieve it .
@user-kl5ur9ee8j
@user-kl5ur9ee8j 2 жыл бұрын
i am done with sending updated location to firebase repeatedly.
@abhisheksatpute1052
@abhisheksatpute1052 3 жыл бұрын
Sir, what is resolvable api exception?
@mafiacodes
@mafiacodes 3 жыл бұрын
developers.google.com/android/reference/com/google/android/gms/common/api/ResolvableApiException
@anshumandhal
@anshumandhal 4 жыл бұрын
Hey, would you be willing to make a tutorial on getting fused location through livedata and observing in view?
@mafiacodes
@mafiacodes 4 жыл бұрын
I can but is super simple just set the location inside viewmodels live data on new location and observe it
@remingtonprince2136
@remingtonprince2136 2 жыл бұрын
Sorry to be so offtopic but does anyone know a way to get back into an instagram account? I was dumb forgot my password. I appreciate any assistance you can give me
@skylarkylo4962
@skylarkylo4962 2 жыл бұрын
@Remington Prince Instablaster :)
@remingtonprince2136
@remingtonprince2136 2 жыл бұрын
@Skylar Kylo i really appreciate your reply. I got to the site thru google and im waiting for the hacking stuff now. Seems to take quite some time so I will get back to you later when my account password hopefully is recovered.
@remingtonprince2136
@remingtonprince2136 2 жыл бұрын
@Skylar Kylo it did the trick and I finally got access to my account again. I'm so happy! Thanks so much you really help me out!
@wisdomking69
@wisdomking69 4 жыл бұрын
getLastLocation() sometimes returns null, sometimes it works its so weird.
@mafiacodes
@mafiacodes 4 жыл бұрын
Don’t worry it’s the emulator thing, get last location return the most recently cached location, so many times emulator does not have a cached location but on real devices this method will mostly not return null
@wisdomking69
@wisdomking69 4 жыл бұрын
@@mafiacodes I tried it on my phone also and it does return null sometimes too. So instead of getLastLocation() I am using the Location Request first and if that is null I will try to get the lastLocation then.
@mafiacodes
@mafiacodes 4 жыл бұрын
Yeah there are chances for that also as in android docs
@robertoanold4719
@robertoanold4719 4 жыл бұрын
Sorry startResolutionfor result didnt work in fragment why
@mafiacodes
@mafiacodes 4 жыл бұрын
It should work as it is not dependent on fragment
@ryanbaltazar9627
@ryanbaltazar9627 2 жыл бұрын
I tried this, but I'm not getting any location information from my Logcat. can you please help me?
@ryanbaltazar9627
@ryanbaltazar9627 2 жыл бұрын
it works on my emulator but, doesn't work on my device
@subhankarsinha8135
@subhankarsinha8135 3 жыл бұрын
If my device is locked will this work ?
@mafiacodes
@mafiacodes 3 жыл бұрын
Depends on the sdk, secondly u should be using a foreground service and then this should work.
@AlphaGamingWorld
@AlphaGamingWorld 2 жыл бұрын
why altitude is not changing
@mafiacodes
@mafiacodes 2 жыл бұрын
on real device. or on emulator?
@AlphaGamingWorld
@AlphaGamingWorld 2 жыл бұрын
@@mafiacodes I fixed that. Actually we need a Location listener, call back and looper for constantly updating location
@Erwinsmith94040
@Erwinsmith94040 3 жыл бұрын
Thanks a lot sir mein 7 din se try kr rha tha pr samjh nahi aa rha tha kaha wrong hua
@Erwinsmith94040
@Erwinsmith94040 3 жыл бұрын
Thanks a lot sir i was shared your video on my social accounts small support♥️♥️
@AtulGupta-jj7ek
@AtulGupta-jj7ek 4 жыл бұрын
Sir the route option you used in the last to demonstrate the updated longitude and latitude is not enabled I mean Play Route button is disabled how to enable it ? And sir I have a request please create a fb group so that your subscribers can discuss problems and help eachother and you also can answer our questions if you get some free time 😊 and also can post anything you want
@mafiacodes
@mafiacodes 4 жыл бұрын
Save the route then select the saved route and then play
@avijitsamanta8784
@avijitsamanta8784 4 жыл бұрын
Sir plz make video on firebase notification
@mafiacodes
@mafiacodes 4 жыл бұрын
Yup will make
@avijitsamanta8784
@avijitsamanta8784 4 жыл бұрын
@@mafiacodes ok thank you ☺
@diego99799
@diego99799 4 жыл бұрын
Unite in pain coding in java
@anandmayeemaity7123
@anandmayeemaity7123 3 жыл бұрын
how to update current location using getLastLocation() ?
@mafiacodes
@mafiacodes 3 жыл бұрын
This would help kzfaq.info/get/bejne/asuHoruBuNalZY0.html
@anandmayeemaity7123
@anandmayeemaity7123 3 жыл бұрын
@@mafiacodes I mean I want to update my current Location because in this video in onstart() in place of getLastlocation() we are using checkSettingsAndStartLoctionUpdate() and getLastLocation() is not used after that . I want to update my current location each time I move. so where do I need to place getLastLocation() ?
@mafiacodes
@mafiacodes 3 жыл бұрын
you need to use the video that I told you to get location updates, getLastLocation only will give you a cached location. So u need to use this video (kzfaq.info/get/bejne/asuHoruBuNalZY0.html) to get location updates as the user/device moves....
@anandmayeemaity7123
@anandmayeemaity7123 3 жыл бұрын
@@mafiacodesOhk!!! Thank you for your guidance.
@anandmayeemaity7123
@anandmayeemaity7123 3 жыл бұрын
Thank you i am able to use it properly. Keep making videos😊
@Rabialshara
@Rabialshara Жыл бұрын
I need help on this matter ❤
@mafiacodes
@mafiacodes Жыл бұрын
How can I help you
@AbdulSamad-yu1zn
@AbdulSamad-yu1zn 3 жыл бұрын
Hii Dear all how are you? I hope you all will be fine. I am facing null lat/long issue as i am using fusedlocationproviderclient... If mobile GpS button is enabled then i get location.. if i disable or reEnable it then i get null location.. if if i close or open app again and again Is there any other service or anything instead of this which works fine??
@mafiacodes
@mafiacodes 3 жыл бұрын
It is ok to get null for location, so u need to check for null location as well, because if u read the docs sometimes the provider returns null location in case there is no cached location.
@AbdulSamad-yu1zn
@AbdulSamad-yu1zn 3 жыл бұрын
@@mafiacodes But Sir i Dont get location for long time even i close or open app again and again
@AbdulSamad-yu1zn
@AbdulSamad-yu1zn 3 жыл бұрын
@@mafiacodes Details In start if my Gps is enabled. and i open app I get location address , lat/long etc. but If i disable the gps or open app it gives all null (because device gps button is disabled) but after that i enable the button then still get null even after closing or opening app again and again
@AbdulSamad-yu1zn
@AbdulSamad-yu1zn 3 жыл бұрын
@@mafiacodes What to do when provider returns null location in case there is no cached location?
@user-ux3qh5px7c
@user-ux3qh5px7c 3 жыл бұрын
@@AbdulSamad-yu1zn hello Dear i have the same problem, Did you solve the problem ??
@bhavyavarmora4049
@bhavyavarmora4049 3 жыл бұрын
BRO if possible please do it in kotlin because their is less video and that all video is not working so please make a video on fetch the location and turn on location and show city name in textView so it will be very helpful for people who are doing first time.
@mafiacodes
@mafiacodes 3 жыл бұрын
well now more android videos will be in kotlin...
@bhavyavarmora4049
@bhavyavarmora4049 3 жыл бұрын
@@mafiacodes if possible can you try to make this in kotlin fetch the location and turn on location and show city name in textview because beginners developer will try to make weather app so it would be very helpfull for them because it's been 2 or 3 days but I have didn't get the right tutorial for this if possible then make it other wise it's ok it's a suggestions from my side because you are expert so it is cup of tea for you to do this and video will be helpful for everyone...😎
@jeronimogabriel1769
@jeronimogabriel1769 4 жыл бұрын
minute 4:50 LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(locationRequest);
@mafiacodes
@mafiacodes 4 жыл бұрын
what about it?
@syedhasan9204
@syedhasan9204 3 жыл бұрын
@@mafiacodes 'LocationSettingsRequest(java.util.List, boolean, boolean, com.google.android.gms.location.zzae)' is not public in 'com.google.android.gms.location.LocationSettingsRequest'. Cannot be accessed from outside package this error please help
Adding Google Maps
10:38
Mafia Codes
Рет қаралды 7 М.
Nastya and SeanDoesMagic
00:16
Nastya
Рет қаралды 43 МЛН
ПРОВЕРИЛ АРБУЗЫ #shorts
00:34
Паша Осадчий
Рет қаралды 7 МЛН
Geofencing | The ultimate tutorial | Create and monitor geofences
54:20
Android: Request Location Updates in the Foreground
10:34
Mohamed Shehab
Рет қаралды 4,8 М.
User Location in Maps
10:51
Mafia Codes
Рет қаралды 17 М.
RecyclerView item Click using Interface | Advanced Way | Android
7:01
Android: Setup Location Services and Get Current Location
16:27
Mohamed Shehab
Рет қаралды 3,6 М.
Get Live User Location - HTML5 Geolocation Tutorial
15:27
OpenJavaScript
Рет қаралды 19 М.
You are using useFetch WRONG! (I hope you don't)
11:14
Alexander Lichter
Рет қаралды 24 М.
Top 10 CSS One Liners That Will Blow Your Mind
13:34
developedbyed
Рет қаралды 933 М.