Create location tracking Android App by exchanging location information over Firebase database.

preview_player
Показать описание
This video shows the steps to setup the location listener in your App's java code. It uses Google Maps API Key to get the google maps in your App. It registers the location listener using the location manager which uses the phone's system service to get location service. This location service is responsible to get the current location of the device/ phone and display it on the edit text boxes - latitude and longitude respectively. It uses both GPS and NETWORK information to get the precise coordinates of the location.

Then it gives an Update button which is responsible to update the location information to the Firebase database. How to configure the Firebase database for your Android Application is shown in details. Though in this App it uses a button to update the database, but the database update can be automated using any desired concept by the App developer.

Finally in the map it shows/ displays the latest location updated in the database. It fetches the database'' data on any change of data and extracts the required information from the datasnapshot variable. A bit of text processing id done to extract only the latest latitude and longitude updated in the database. The information of the latest latitude and longitude is used to move the camera on the map and put the marker accordingly.

Complete project source code of this tutorial is available at:

Рекомендации по теме
Комментарии
Автор

I have understood the problem. I have changed the scheme of database, and then I run the for loop ..now it works!! Thank You!
Daniele

danieleiovinelli
Автор

P. S. So maybe Have I to create an arrayList?? Thanks

danieleiovinelli
Автор

So I have to do a for loop for each datasnapshot like you have done in your tutorial adding an eventvaluelistener... And than checking for evry id the value for latitude and longitude? And if I want, is it possible to do pushing another button, that I have created?
Thank you and sorry for all this questions, but I miss the basics of Android studio and its Java objects. Bye..
Daniele

danieleiovinelli
Автор

Shall we use this to track real time public bus??

sudharshanprakash
Автор

if we use cloud firestore it's cost is - $0.06 per 100, 000 documents
so according to that if we update the location every 30 seconds the cost per user is
24hr * 60 min *30 sec = 43, 200 Document write only for single user .
my calculation is right ? i want to use firestore but for locaiton update application its not prefereable it think.

cnwit
Автор

Thanks, but you should zoom it a little, it's very annoying to stop vid every 5 sec and open full screen.

Arekadiusz
Автор

so what id the purpose of adding an update button? it is not a smart way that the user press update every time he moves it should automatically move the marker

yehya
Автор

hello sir.. can u help me? did u know how to make vehicle tracker application using gps tracker? im stuck on how can i do to connect my application with the gps tracker

aidaaramlee
Автор

Greetings sir, first of all, this one is great! Appreciated it. I was making an app with this as a base but I cant figure out how the maps is not showing in the app. Though the geolocation is working as well as the database. Hope I can hear from you soon.
thanks
-Sky

skyvisio
Автор

excuse me,
This is geolocation api
Are you using?

try
Автор

Hello mate great tutorial I appreciate it but one issue here latitude and longitude are shown of Google office on emulator but when I use my android phone no marker is shown

Sheikhhamiz
Автор

Hi! I have done a for loop on datasnapshot with the valueeventlister... But it doesn't work... The marker shown it is just the last one that I add in the previous usage... Then when I reopen the app... I see just this last position... Is it possible that there is an incompatibility of using valueevent listener couple of times?? Thank you

danieleiovinelli
Автор

Thank u sir it synced successfully i rebuilted my project as u told

sudharshanprakash
Автор

sir this video helps me a lot,
but i, ve one question? can you suggest me how can i show my firebase latitude & longitude info in another app through google map, i mean i wanted to make vehicle tracking app, in where one is driver app, another one passenger app. pleaseee sir make another video that can receive this firebase data for vehicle tracking.
pleasee sir help me, i'm stuck on my course
project

abcdshikor
Автор

I have a question for you. I am trying to extrapulate, also all the previous positions of my database and adding them as markers on the map. Is it possible, just when the application starts, or also adding a new button...?? I want to see all the previous positions every time the app starts.
Let me know Thanks

danieleiovinelli
Автор

does the android phone needs to be connected to internet(wifi/mobile data) for it to be tracked? or just turning its GPS is enough for tracking it?

ayushmanandhar
Автор

The line of code below is not working in Kotlin. I guess it's asking for a looper. Can you help?
try {
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, MIN_TIME, MIN_DIST, locationListener);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME, MIN_DIST, locationListener);
}

ezscootrr
Автор

is it expensive using firebase as database in location tracking apss?, because there must be using many read/write operations

mcdyesscoy
Автор

i have done same as you but after running the application ''unfortunately LocationTracker app has stopped" is coming. I have gone through logcat window " databaseReference= " at this line error is showing..please help I need this for my project

osamasiddique
Автор

hi sir, what about firestore? can you do tutorial on firestore because the method might be different than database

ooyen