How to design a location tracking App using GPS in Android Studio - source code?
HTML-код
- Опубликовано: 6 сен 2024
- This video shows the steps to create an App which uses Google Map to give the precise location of your phone. This app can be used to track your current position. In the initial part of the video it shows how to create API Key to have the access of the google Map.
This custom app works offline based on GPS and you do not need internet connection to get your current location.
For 2nd part of this tutorial please refer to the below video: • How to track your loca...
Complete Source code is available at:
programmerworl...
We will be glad to hear from you regarding any query, suggestions or appreciations at: programmerworld1990@gmail.com
I am pasting the main method code below (for complete class please contact):
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
locationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
try {
latLng = new LatLng(location.getLatitude(), location.getLongitude());
mMap.addMarker(new MarkerOptions().position(latLng).title("My Current Position"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
}
catch (SecurityException e){
e.printStackTrace();
}
}
@Override
public void onStatusChanged(String s, int i, Bundle bundle) {
}
@Override
public void onProviderEnabled(String s) {
}
@Override
public void onProviderDisabled(String s) {
}
};
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
try {
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_UPDATE_TIME, MIN_UPDATES_DISTANCE, locationListener);
}
catch (SecurityException e){
e.printStackTrace();
}
}
}
Sir, you really save my life. God bless you and your family
The marker shows up but not the actual google map. Just shows a red marker on an empty page.
That is because your maps has not been downloaded in your App. This usually happens when there is network issues and internet is not accessible or it is very slow. The marker shows up because it is independent of network. It uses phone's gps to get the coarse location.
I will recommend to check your mobile data or wifi in your phone. If you are trying on the emulator then please check if other Apps, such as Play Store, is able to access the internet. For emulator sometimes you may have to do proxy settings if you are in a LAN environment. You can do the proxy settings from the Android Studio->Settings window. Just search for http in the settings window.
Hope above details helps in resolving the issue.
Good Luck
Programmer World
programmerworld.co
-
@@ProgrammerWorld The map and marker are now showing but the marker is in GooglePlex , USA. Is this because I am using an emulator and not a real phone?
@@YSNR.25 Yes, exactly. It shows California USA, because you are using emulator. Emulator can't access your location information from your laptop as GPS functionality is not available and Network location information is not shared by the laptop's OS. So, it takes the default location to be at Google center in US.
In real phone it should work as the App will have access to both GPS (Coarse) location and Network (Fine) Location.
Cheers
Programmer World
programmerworld.co
-
10:01 Once I start to type the exact same code in line 29 & 30, it show ActivityCompat is not cannot be resolved. Could you help me?
For ActivityCompat, you may have to import the following package in your java code:
import android.support.v4.app.ActivityCompat;
In Android Studio, it should automatically import the packages used in the code. However if it is not doing then you can try adding it manually. You can also refer to the below page where I have shared complete source code shown in this tutorial:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
Hope it helps. Good luck!
Hi thanks for the video works awersome!!! Hi just comment out the following lines your code to get the Sydney pointer off the map
// Add a marker in Sydney and move the camera
//LatLng sydney = new LatLng(-34, 151);
//mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
//mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
sir i would like to know can we make it run in background always so that we can register a number in it and we should be able to send the location every 1 hr that's 24 hrs a day 24 messages per day..
it would be useful right??
Yes, sure that is possible. You should watch my below videos to get the steps on creating foreground services which keeps on running in background even when the App is closed.
ruclips.net/video/MRm6NgZlmDc/видео.html
ruclips.net/video/xxC4-BLNSSc/видео.html
Cheers
programmerworld.co/
@@ProgrammerWorld mlmmmmmmkmmmm knkkknkknkkkkknkn kknnkkkmkm.. Mmkm mmmmmmm n
@@ProgrammerWorld kknnkokkokkkokokknkk nnkk kk kn knn jonkokoknkokoknjoo kioki
@@ProgrammerWorld ookkkkok kk
I am getting error in a statment
locationManager=(LocationManager) getSystemService(LOCATION_SERVICE);
Can you help me out??plz
What is the error? Can you please give more details?
Cheers
Programmer World
programmerworld.co
-
@@ProgrammerWorld its ok, i fixed it
Great 👍👍
Good Luck
Programmer World
programmerworld.co
-
Sir could you do a project for one tap emergency SMS which will trigger the alarm sound as well as the video camera. I'm doing this for my FYP and im struggling cuz im not familiar with android studio and don't know where should i start. It will be great if you can help me. Thanks in advance
Thanks for the suggestion. Will try to create some material as you suggested. However, some of the things are already available in my below videos:
ruclips.net/video/pajvuBZc2WA/видео.html
ruclips.net/video/KAKn6XdMaxM/видео.html
Cheers
Programmer World
programmerworld.co
-
Great work done by this guy
according to you how we could be good in making apps from beginners to expert. what are the sources you recommend us to understand the complexity of making the apps and sites
This is very subjective question. However, in simple words:
1. Take a basic tutorial from some trainer.
2. Ensure you know the programming (any language: C/C++, Java).
3. Then practice - you can refer to my channel for practice exercise.
Also, you can refer to my below webpage for lots of practice exercise on Android App development:
programmerworld.co/android/
Good Luck
Programmer World
programmerworld.co
-
This works, if it's in the main activity, but if I put the same code into a service it starts bugging out after restarting the phone when the service is set boot with the device. Any ideas? If the code is in the main activity, it will call on status changed then I have 1 toast to confirm this happened then it will gather location every now and then. If it's in the service the location gets gathered, it will show the toast MULTIPLE times, then it gathers the location? I'm expecting 1 toast then gathering location. It can toast everytime after it polls the location, but it shouldn't be giving more than 1 toast per location grab. As stated, when the code is in the main activity it works as expected 1 toast per 1 location grab. I need ideas.
Most likely, when the code is in the service class, it is repeatedly getting called due to frequent call to service class by the Android OS. Now, since there is no way for the class to know whether the Location has changed from the previous known location, so probably it calls onLocationChanged every time the service class is called.
Probably, one way to avoid this would be by updating the last location information in the app using the FusedLocationProviderClient API. Below webpages may help:
programmerworld.co/android/how-to-get-the-device-last-location-using-gps-network-without-using-map-layout-in-your-android-app/
programmerworld.co/android/how-to-requestlocationupdates-if-locationservices-getfusedlocationproviderclient-getlastlocation-always-return-null-value-in-your-android-app/
For reference, details shown in this video is also shared in the below link:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
Cheers
Programmer World
programmerworld.co
-
hi, can you please do a tutorial how to know the distance from a phone to a laptop using Bluetooth tracking please please . I
need your help by using java if I may .
i am not able to find google maps api file what to do?
hello sir how are You ? THNAKS for this video it was very helpul .i wanna make an app which will search a place location and i need help
Sir can you please share me the link for next video that you mentioned in the Location Tracking video
You can watch next videos in this series using below links:
1. How to send location coordinates offline without internet over SMS: ruclips.net/video/FknRti6n_F8/видео.html
2. How to send location information using Firebase database: ruclips.net/video/hyi4dLyPtpI/видео.html
3. How to get exact location information and address using the latitude and longitude coordinates: ruclips.net/video/Nsl99WWDFxM/видео.html
I hope above tutorials helps you.
Cheers
Programmer World
programmerworld.co
-
I just one question sir how can I show the marker quicker because sometime when i open the app it takes time to show the marker on the map thankyou for this tutorial
mMap.addMarker method call is responsible to add the markers in the maps. Now, once the Map is loaded and ready in the App (calls onMapReady method) then only the marker can be added. To speed up the loading, you can check for this method in the onCreate method of your App. It may help.
For reference, the complete source code shown in this tutorial is also shared in the below link:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
Cheers
Programmer World
programmerworld.co
-
@@ProgrammerWorld thankyou man I will try and I'll be back here
I'm a newbie to Unity and App development. I want to create an AR navigation app in Unity using the Mapbox SDK and I've been told that it's possible by combining the world scale AR example with the Traffic and Directions example but I can't figure out how. Any ideas?
Yes, you are right. It is possible to create AR navigation App in unity using world scale AR example with Mapbox SDK. I do not have video tutorial to explain how to do it, but you can refer to below link which gives further details on how it can be done. I hope it helps:
docs.mapbox.com/unity/maps/examples/world-scale-ar/
Right now I am focusing on creating Android tutorial. I need support from my audience by subscribing to my channel so that I can create more tutorials to help my audience.
Hi. I'm just starting to write programs in the android studio and I have already found one of your videos for which thank you very much. I have a question. is it possible to set the default distance from the marker of our position in this script? do you have to zoom in from the continent and countries each time? I would like to enter the location in my future application, but I would like it to immediately show my position in the area, e.g. 50km from me. will it be difficult to implement? Regards.
In the moveCamera method's parameter, please use either CameraUpdateFactory.newLatLngBounds or CameraUpdateFactory.newLatLngZoom to set the camera view at a particular zoom level.
In the code shown in this video, below line is used which takes default zoom level at the given lat and lng:
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
For reference, the complete source code shown in this video is also shared in the below link:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
Cheers
Programmer World
programmerworld.co
-
@@ProgrammerWorld thx man ! Program work but in my position i have many markers. Every 1 second app create new one. Maybe i can change some code, and new Mark show when i change my position , but not than 1 second. Have you some advice for that? What do you think, maybe i can add Button , and when i click on it , program refresh position? Or maybe its possible on your code and i dont know how 😁
Change below variables in your code:
private final long MIN_TIME = 1000; // 1 second
private final long MIN_DIST = 5; // 5 Meters
The markers is placed when either of above is true. That is, either every 1 second or every 5 meters distance change.
For reference, the complete source code shown in this video is also shared in the below link:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
Cheers
Programmer World
programmerworld.co
-
Can I do the same technique but with some changes for indoor by BLE beacon ?
Conceptually it should work as the tracking mechanism remains same. However, I have never tried myself to map the location based on Bluetooth beacon sensor data.
Nice
Hii sir, I have used the same code to create this app but it keeps stopping as soon as I open it.......please help me why is it happening?
Try to debug and check for the reason of crash. Most likely the onCreate method is crashing. Better put a try-catch for smooth handling. Also, crashes during the start is most of the times due to null pointer exceptions. Please debug and check.
For reference, the complete source code shown in this tutorial is also shared in the below link:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
Cheers
Programmer World
programmerworld.co
-
hello sir... my location showing Sydney...my current location not showing...
Sydney is the default location. If your current location is not getting updated, then it means either the location services (GPS or network) is not working in your phone or in your App's code it is not reaching the location listener part of the code. I will suggest to debug the code and check the flow of your code.
Good Luck
Programmer World
programmerworld.co
-
Hi sir thankyou for this, i wanted to know how can we make a login and register thing so that we can integrated it with this and keep the data base also
You will need a database to store user credentials and then match it against the login page. So, the login page will depend on the db. There are many videos on various database, such as Firebase and MS SQL, on my website:
programmerworld.co/android/
Also, below page can help to design multiple pages/ layout in your App:
programmerworld.co/android/how-to-create-multiple-layouts-and-menu-items-in-your-android-app-switch-layout-and-exit-menu-options/
Hope above helps. For reference, the complete source code shown in this tutorial is also shared in the below link:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
Cheers
Programmer World
programmerworld.co
-
sir the app is running fine but it is not showing my position and only shows marker in sydney
It may take sometime in the first run, so wait for 4-5 mins if it is first run. Also, please ensure that internet is available during the first run (to download the map) and GPS satellites is accessible for getting updated location (go outdoors is possible).
Good Luck
Programmer World
programmerworld.co
-
@@ProgrammerWorld thank you
It works !! Thank you !
hello sir, i m doing women safty security with GPS project
but sir i don't how to connect GPS system in my project
so plz sir can u suggested me sir plz
i m learner
i saw your vedio sir ,its very interesting sir
so plz help me sir
I think this video should have helped in learning the connection to GPS in your App. Also, you can watch my below videos for further information on location tracking applications:
ruclips.net/video/hyi4dLyPtpI/видео.html
ruclips.net/video/FknRti6n_F8/видео.html
Good Luck
Programmer World
programmerworld.co
-
@@ProgrammerWorld okk sir thank you
Sir can u give me whatsApp no.
Plz send me no. On Gmail plz
Hello Sir. I am using your tutorial to make a system which tracks the movement of a vehicle. In your tutorial, you have used marker to show the path right? What can I do to make it a straight line?
Also, I would like to use external GPS coordinates that are received to my phone by bluetooth. How can I do this?
Your help is highly appreciated.
Regards.
For getting it in straight continuous line you can put the marker more frequently however it may not appear very nice. Will check on how to get aesthetically appealing tracking in map.
For 2nd question, you should watch my below video which shows steps on how to pass/send the latitude and longitude coordinates to another phone through SMS. Of course, you will have to adapt it for transfer of data over Bluetooth:
ruclips.net/video/FknRti6n_F8/видео.html
If interested you can watch my below video which shows steps to convert latitude and longitude coordinates into an actual address:
ruclips.net/video/Nsl99WWDFxM/видео.html
Cheers
programmerworld.co
@@ProgrammerWorld Thank you sir for your response. I am a beginner and hence have limited knowledge. As far as I checked, it is possible by using Polylines. Could you please have a look into this? My idea was to include a polyline function and call it in place of marker.
I did try the sms tutorial. While the location tracking worked, the sms part did not. The initial request for sms permission also did not work. I tried both in emulator and phone. And then I copied the code from your site too. It still did not work. Could you please help me out here?
Thank you
I will check Polylines command as mentioned by you. Regarding the SMS communication, did you try the source code in my below webpage:
programmerworld.co/android/how-to-send-sms-automatically-from-your-phone-by-programming-in-android-studio-java-code/
If yes then can you please let me know the error you are getting? Can you please share your complete code so that I can try at my end.
Cheers
programmerworld.co
@@ProgrammerWorld Thank you for your response. Please do let me know when you are done with polylines.
I had copied from your link. The problem is that it is compiling but showing no error. But the sms part doesnt work. I have given my code below:
package com.example.locationtracker;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.FragmentActivity;
import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.telephony.SmsManager;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
private LocationManager locationManager;
private LocationListener locationListener;
private final long MIN_TIME = 1000;
private final long MIN_DIST = 5;
private LatLng latLng;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
ActivityCompat.requestPermissions(this,new String[]{Manifest.permission.SEND_SMS}, PackageManager.PERMISSION_GRANTED);
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, PackageManager.PERMISSION_GRANTED);
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.INTERNET}, PackageManager.PERMISSION_GRANTED);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
locationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
try {
latLng = new LatLng(location.getLatitude(), location.getLongitude());
mMap.addMarker(new MarkerOptions().position(latLng).title("My position"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
String phoneNumber = "9999";
String myLatitude = String.valueOf(location.getLatitude());
String myLongitude = String.valueOf(location.getLongitude());
String message = "Latitude = " + myLatitude + "Longitude=" + myLongitude;
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNumber,null,message,null,null);
}
catch (Exception e){
e.printStackTrace();
}
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
};
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
try {
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, MIN_TIME,MIN_DIST,locationListener);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,MIN_TIME,MIN_DIST,locationListener);
}
catch (SecurityException e){
e.printStackTrace();
}
}
}
Your code looks good and it should work at your end as well. Just a quick question, have you defined the required permission (Access to coarse and fine location) in your App's manifest file? I think that could be the reason for your SMS sending and reading permission issue. If possible, can you please share your manifest file as well?
Hello sir could you please do android studio app on my journey tracker thank you ☺
I think project shown in the below link will help to create a journey tracker App and keep a log of locations visited using a database (Firebase database):
programmerworld.co/android/create-location-tracking-android-app-by-exchanging-location-information-over-firebase-database/
Cheers
Programmer World
programmerworld.co/
-
hello sir great video
I have qustione I am trying to develop and app that is linked to smartwatch the app should track the smartwatch location..,should I develop app for the wear also to get the location or should I develop a watch face and get lotion form or is their another solutions
thank you
I will suggest the best option is to develop an App for smartwatch wear.
Good Luck
Programmer World
programmerworld.co
-
umm..... for me it doesnt get updated on my mobile phone the marker is still in sydney no matter i give location access or i reinstall the app.PS: my internet connections are good
Then please debug the code and check where it is failing.
Concept of this App is very simple. You get your position based on gps data and network access to your App. That translates to latitude and longitude values. And finally, marker is moved based on these updated values.
Please can you help me? I do everything and it doesn't trigger the app, it crashes.
Debug your code, put a break point and see where the App crashes. Also try to wrap the part of the code using try-catch to better handle the exceptions thrown. Let us know the exception the App is throwing (when it crashes) and we will look into the issue.
Cheers
Programmer World
programmerworld.co
-
maybe monitoring the logcat(bottom of AS window) might be a good idea from time to time :)
Hey … yes, nice suggestion.
Thanks
Programmer World
programmerworld.co
-
Hi I installed the app and it is working , but there is one problme if I am zoom in I am getting many locations not only one location of mine....can you help me out with that.
Because in the code, I have just shown to add markers. I am not clearing them up for every location update. So, whichever points you move to, those will show on the map as static markers.
To refresh it, you will have to clear the map on the update of location listener before adding the marker. This way the map will just show your live location with the marker.
Good Luck
Programmer World
programmerworld.co
-
@@ProgrammerWorld okay know I shared my app by apk extracting the app installed in other mobile through apk is not showing the map and location ..pls can u help me.
package is transferred in the emulator device . then it saying that "com.example...." has stopped , if i click again then it says keeps stopping
Basically, your App is crashing in the onCreate method itself. I will suggest you debug the code and check the reason for the crash.
If required, you can refer to my below video for steps on debugging:
ruclips.net/video/Y_y2jR1GSC8/видео.html
Also, if needed, you can refer to the complete source code of this tutorial at the below link:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
Good Luck
Programmer World
programmerworld.co
-
hello sir the application is working but whenever it changes the location new pinpoint appear then the previous pinpoints will remain. how can i remove those previous pinpoints and only have the newest one. The other problem is, we tried this on 4 different phones, for the 2 phones it run smoothly it can locate the exact location no problem at all (just the pinpoint) but for the other 2 it cant locate its location. and for the last one, is it possible to draw an object in the map? for example a circle with a pin point located at the center. Thank you!!!!!
- how can i remove those previous pinpoints and only have the newest one.
Just add mMap.clear() to remove all the markers before adding the new marker.
- The other problem is, we tried this on 4 different phones, for the 2 phones it run smoothly it can locate the exact location no problem at all (just the pinpoint) but for the other 2 it cant locate its location. and for the last one
Just ensure that GPS and Data network is ON and location access permissions (Coarse and Fine) both are granted to the App in the phone. Also, sometimes in some phones there may be restriction on using certain permissions for the user Apps. Just check that by going to Settings->Apps->Permission. A quick fix for this will be to just reinstall the App after removing the App (including the App data).
- is it possible to draw an object in the map? for example a circle with the pin location in the center of the circle.
There are lots of properties of markers which allows to customize the shape, color, size, etc. of the marker. As of now we do not have a video to show this but below page will help you with this:
developers.google.com/maps/documentation/android-sdk/marker
Hope above details helps.
Cheers
Programmer World
programmerworld.co
-
Hi bro, I want to trace the geolocation of some devices which are locally connected via ethernet mode. Is there any free API to embed this feature?
Sir how can we retrieve location from firebase ....
Which is already sent to firebase through raspberry pi using GPS module
Hi,
It can be simply done by getting the instance of the Firebase database and then reading the data. It has been explained in the below article with source code (though a bit complex). I will try to make a simple video on this topic and post it here when I get time.
www.androidauthority.com/create-a-gps-tracking-application-with-firebase-realtime-databse-844343/
its not showing my current location instead showing marker in sydney
If your code is correct, it should work. However, in emulator it may show your position as California irrespective of your current position.
But in real phone it will work. Though it may take some time on first time run as it will need to download the map.
Also, please ensure that the access to coarse and fine location (GPS and network data location) is granted as it will be used to update your location.
i am getting a blank page with the word google at the bottom and no map
Please ensure that network access is there on the phone which is needed to download the map in the first time.
Good Luck
Programmer World
programmerworld.co
-
Is it possible to add a schedule of locations where the person goes and get the notification if the person is out of that routine location?
Yes, it will be possible.
Based on the latitude and longitude information, you can keep a check. The moment the current location of device goes out of bound of the allowed latitude and longitude, then trigger the alarm.
Cheers
Programmer World
programmerworld.co
-
@@ProgrammerWorld thank you...but i want the alarm automatically...
very nice video
Hello , to actually see the change in Location would I just have to move to a different location with my laptop and then re-run the app? Also i dont know why it automatically shows california location when I run the app, any reason for that ? Thank you
This App cannot be tested on the laptop (Emulator) because the location sensors such as GPS is not emulated in the emulator. To test it please use a real phone or device.
The location in an emulator shows California because by default emulator takes the Google's headquarter as the location of the AVD.
Cheers
Programmer World
programmerworld.co
-
Hello sir I have doubt that if we want to track other phone number to help then whether the person should need tracking app or the one who want to help need the app
Dear Chandana,
The person who wants to share his location will need this App installed on his phone and not the one who wants to help.
Along with the location tracking App, you can see my other video (link below) which shows how you can send automatic SMSes to the another person. So, the person whose phone needs to be tracked should have location App with SMS functionality so that he can send the latitude and longtitude information to another person who wants to help.
ruclips.net/video/pajvuBZc2WA/видео.html
Its working on the avd,bt it not showing location on the mobile.why?
Check if your App has access to location information from your phone. It should have access to both GPS info and precise location based on your mobile signal.
You can check this by going to Apps permissions in your Android phone setting.
Let me know if you continue to face issues.
Is it possible to make gps car's vector and track at random point of a drive their statistics like app ?
Yes, it is possible. In the App code what I have shown is that you will get latitude and longitude of the position of your GPS device (Android phone). You can collect these information like latitude and longitude at different time stamps and then create a statistics out of it.
In the video I have shown to update latitude and longitude information on the map. But for your requirement please store them in variables and then various statistics can be drawn from them.
I want to get the crime record for the particular location, how can we code for that so we can get the crime data for that individual location while we enter
For your requirement, the crime record for the locations should be stored in a database. Then that database values should be accessed and plotted on the map. Something similar to what is shown in the below link:
ruclips.net/video/hyi4dLyPtpI/видео.html
Cheers
Programmer World
programmerworld.co
-
hi bro how are you?can we use offline google map for get current location?
Yes, I think you can work in offline mode if you have used the location tracking based on GPS also along with network in your App code.
However, for the first launch of your App network would be needed to get the Maps configured in your custom App. Accessing pre-saved google maps may not be possible as your custom maps will not have access to the google map App data on your Android phone.
Hiii i want to update location even when app is in background ???? So hw cn i do it
You can use the foreground or background process to run it in the background.
I do not have any video for background process yet.
However, for foreground process you can refer to the below videos:
ruclips.net/video/MRm6NgZlmDc/видео.html
ruclips.net/video/xxC4-BLNSSc/видео.html
Cheers
Programmer World
programmerworld.co
-
my application keeps "stop work" what can i do
There are 2 options:
Either debug your code and check at which line the code is breaking. To debug you should start the emulator in debug mode and put break point at the start of your Java code file.
Else 2nd option is encapsulate your code in various try catch and check the exception thrown in the catch part. Then you can program the code to take appropriate action in case of exceptions thrown.
In general my guess is in your code it is not able to get the GPS reading and hence while reading latitude and longitude it is failing. However, of course I can't be sure unless we debug the code.
Hello i cant run app, the first time i run it into the emulator i getting an error trouble with google play services
Then it implies that in emulator, it has issues to reach Google. Either due to network issues or your Google login account issues (incorrect login details). This App may be requesting for Google services to access Google Maps, though I am not sure. In my phone/emulator, Google Play services are logged in so I have not observed such issues.
Cheers
Programmer World
programmerworld.co
-
sir when i started the app for the first tym it just showing the white screen with google icon on left bottom my internet speed is 6-7 mbps what should i do
and how much it will take to download the map
It should not take more than 2-3 minutes. If it is taking more than 5 minutes then something is wrong. Your App is not able to connect to the Google Map over internet. Don't wait further.
@@ProgrammerWorld Tq for the reply sir
Hi , I typed the exactly same code , but when I run it , it just didn't show my location.. why?
I assume all the necessary permissions are defined in Manifest file and your Java code. If yes, then let us know if you are getting any error. If no error is thrown then request you to debug the code to check for the issue.
By the way for reference the complete source code shown in this video is also shared in the below link:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
Cheers
Programmer World
programmerworld.co/
-
@@ProgrammerWorld the only difference is that when I do the locationListener = new LocationListener() , it creates just the onLocationChanged(@NonNull Location location) and the other 3 are not created.
@@ProgrammerWorld Update : I resolved it. My phone was the problem , I have an Huaweii and I don't know exactly why it doesn't work on it.
One question: Do you have a project where I can see how to implement another location and show me how to get there from my location?
Sir how to create api key. .I have try many tyms but not generated please help me..
To create API key, you will have to login to your Google account using the link which you get in the google_maps_api.xml file. Then follow the steps through the google page. This is shown in video from 2:22 min to 03:36 min.
Also I hope you have selected Google maps activity while selecting the activity for your App. This is shown at 1:20 min in the video.
If the above information doesn't resolve your issue, then let me know what specific problem you are facing. I will try to help you.
Sir , I am not getting accurate loaction
Location shown on map is 300m away from my actual location
Pls help
Try to use Fine location in conjunction with Coarse location access. It should solve your problem. If required, the complete source code has been shared at the below link. Please refer to it:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
-
Hi, is there a program one can run on their laptop to bring up video file based on GPS location?
There are lots of Apps now for laptops also. By the way which OS you are using and if you can give example of any specific use-case then it will help us to understand you query better.
For reference, the complete source code shown in this tutorial is also shared in the below link:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
Cheers
Programmer World
programmerworld.co
-
same problem sir marker not showing in my location
What is the minimum SDK version you are using? Is it SDK 26? And what is the SDK version of your emulator or smartphone?
API Level 27
For API 27, it should work because that is what I also used. So, the only suggestions I can offer is to try debugging the code.
ok sir thanks ...
@@nehaljathar3691 did it work? same problem
Hello brother I had a doubt that how we can track the location when the user doesn't accept our request.... If the user accepts the location doesn't share.... If the user doesn't accept the location need to be share..... Kindly tell how would to be create this....
Hi Subair,
If the user does not accepts the request to share the location to your App, then there is no way to get that information. Of course there are ways you can get the developer rights of the phone and then hack the phone to get the location information. But google is very sensitive to these approaches and it is is highly discouraged to try such approaches. Also, it is beyond the scope of this video tutorial.
If the user accepts to share the location info of his phone to your custom App, then voila you have all the information. Please watch 2nd edition of this tutorial at: ruclips.net/video/FknRti6n_F8/видео.html . Here, I have also shown that once you have the location information how you can send it or share it with someone else over SMS.
I followed this code, but it is still stating that I am in the location provided on the video whereas I am based in Maryland.
So, does your location shows Sydney or California? .... If it is Sydney then it means your location listener is not working (either gps and network is not providing updated location or your App is not getting location updates from these sensors due to issues like permission not granted for the location access).
Else if your location is showing California then it means that you running your App on the emulator. On emulator, as I have explained in another comment, sometimes the location information is not passed to emulator from your PC network.
See my reply to Saish Sawant's comment around 2 weeks back for details on this.
can you please teach how to develop wireless vehicles tracking application please
Apart from this current video tutorial, you should refer to my below tutorials which covers the topic of wireless tracking of a vehicle either in online (using internet) or offline mode (using SMS):
programmerworld.co/android/create-location-tracking-android-app-by-exchanging-location-information-over-firebase-database/
programmerworld.co/android/how-to-track-your-location-using-gps-and-send-it-over-sms-in-your-andoid-app-complete-source-code/
programmerworld.co/android/how-to-convert-latitude-and-longitude-location-to-an-actual-address-and-show-on-map-in-android-app/
Good Luck
Programmer World
-
hello, what i need to do to update my marker when i move and remove the last marker in real time?
Hi,
I did not show in my code to remove the previous markers because I liked the trail mark it showed for all the points my phone has reached.
However, if you want to remove the markers in your map, you can easily use the CLEAR method for your google map object. Try the below command in your Java code just before adding the new Marker. It should clean up all your previous Markers from the Map:
mMap.clear();
@@ProgrammerWorld it s working, thx
Some person are using fake gps app in mobile , can we stop or authorized our app to take only right location.
Send me code plese
If you are getting the location service from the system then no other App can manipulate the data provided by the Android OS (system). So, please use below line of code to define your location manager. This will ensure the accurate location information (GPS values) are retrieved.
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Complete source code for these Apps can be found in the below links:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
programmerworld.co/android/create-location-tracking-android-app-by-exchanging-location-information-over-firebase-database/
Good Luck
Programmer World
programmerworld.co
-
Hi!Can you show how to build family locator app with kotlin language? I already searched gps tracker with koltlin language but I didn't find anything.
Java code can be converted to Kotlin using the Android Studio itself. So, one can inter-change between Java and Kotlin code in the Android Studio environment.
Moreover, for family locator you can also refer to my below videos also (Though these are also in Java):
ruclips.net/video/hyi4dLyPtpI/видео.html
ruclips.net/video/FknRti6n_F8/видео.html
Cheers
Programmer World
programmerworld.co
-
Dear bro please contact me.. I need one project from u... Thanks
8794423709
My watsapp no
Every time I open the activity, I get a blank map. Any help?
For the first run, App will download the map. So, if you are getting blank map, it may be due to network connection issues. Please check whether the network is working on your device (emulator or actual phone).
@@ProgrammerWorld getting blank map too, Internet connection is fine.
@@slobodannesic9175 Then please check your API Key.
@@ProgrammerWorld Yeah I fixed it. Just had to enable Maps API in console. Had the key.
@@slobodannesic9175 Great 👍
I have gps device .... But i dont have application to track it... Can u help me please
Yes, sure. What kind of assistance do you need? Please let me know. By the way what kind of GPS device do you have? Is it Android based?
You can also watch my another video on this topic which shows sending location coordinates using SMS: ruclips.net/video/FknRti6n_F8/видео.html
Also, if needed you can contact me at our email ID: programmerworld1990 at gmail dot com
Sir we connect drone with this app through a camera
Yes, you can use this App for drone also by connecting any Android device connected with your drone and running this App on that device. However, I didn't completely understand the utility of camera. Can you please explain how you are harnessing camera utility with this App.
Further, I would suggest you to watch my next videos on this topic which can be used to track the drones location remotely.
In the below link it explains the steps to use Firebase database to store location information:
ruclips.net/video/hyi4dLyPtpI/видео.html
In the below it explains the steps to send location cordinates without internet over SMS:
ruclips.net/video/FknRti6n_F8/видео.html
Cheers
Programmer World
programmerworld.co
-
hi sir, can u do a video how to do a android application that can track pets with gps
Dell laptop generation 6 with RAM 4 GB ,
processor Intel core i5 6200U CPU 2.30GHZ to2.40GHZ,
OS 32BIT, x64-based processor
it's speed so much slow .and i want to increase the speed of laptop by increasing RAM @t tell me what changes i will make so that android stdio software work very friendly manner and speedy way.?????
should i buy new laptop for android stdio Software
sir g recommended me you opinion
i am waiting your reply
plz reply me
4GB RAM should be fine for Android Studio. It should work. But I think you will face issues while running emulator. So, I will suggest if you want to use Studio and emulator both simultaneously then please upgrade to at least 8GB RAM. In 16GB RAM, the performance will be best. But check your budget. Try to upgrade to at least 8GB RAM.
Good Luck
Programmer World
programmerworld.co
-
How can we send the location of the person to the registered phone number without internet
Hi,
I think the only other way (without internet) to share your location details would be through sms. Get the latitude and longitude information using GPS in the map and send it through SMS to other person. Of course for this one will need access to SMS service in the location app. This can be done by updating manifest file.
Will try to make a video on this concept when I get time and share it on my channel.
Hello Everyone i had the same error. of the marker not showing my location change LocationManager.GPS_PROVIDER to LocationManager.NETWORK_PROVIDER
first time, the app didn t show me my real location, it was only the sydney mark, but now with NETWORK_PROVIDER it s working. u re a life saver. thx!
You can try both NETWORK_PROVIDER and GPS_PROVIDER in your code by implementing it as below:
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, MIN_TIME, MIN_DIST, locationListener);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME, MIN_DIST, locationListener);
This will increase the chance of getting the exact location from both the sources - GPS and Network.
However, just using GPS_PROVIDER should have worked on your phone. The only caveat is that you will have to ensure that GPS Satellite is clearly visible to your phone. For that you may have to go in open area for few minutes.
i had a doubt that how can i connect a tracker to this app to track the vehicle which was integrated with a tracker.do we have any special key to connect with it?
I am not sure what you mean tracker here. If you mean that you want to track a device then you can do so by transferring the location info from tracked device to another device. You can watch my below videos for steps on passing the location info either through database or over SMS:
ruclips.net/video/hyi4dLyPtpI/видео.html
ruclips.net/video/FknRti6n_F8/видео.html
Good luck
Programmer World
programmerworld.co
-
@@ProgrammerWorld Tq very much. But can you please tell me how to make an app which can receive lat and long from a tracker. Here tracker means I mean a GPS tracker SIM card included init .
And also will there be any kind of connection between a tracker and our app to connect
@@dugyalavigneshkumar4201 To receive information from tracker in your Android App then it is important to understand the channel used by tracker to send the information. Is it through SMS/ other messaging app (WhatsApp, etc.) or through any database such as Firebase? Based on communication channel you can design your Android App to receive the information.
I have video on most of these concepts. You can browse through my channel to refer to the respective video. Else please let me know the communication channel your tracker uses.
Good luck
Programmer World
programmerworld.co
-
hello . My requirement is to create an ambulance tracking app using GPS device. Could you please help me.
Sure, please tell me what kind of help you need. However, you should watch my below video in which it is shown how to share the tracked location over SMS:
ruclips.net/video/FknRti6n_F8/видео.html
hello how do i connect this app to arduino?
Can you elaborate a bit more on your use case? It will help us to understand the issue better. However, this App is for running on Android device. So, to exchange the data with the Arduino device, one will need to do it over the Arduino interface for Android.
For reference, the complete source code shown in this tutorial is also shared in the below link:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
Cheers
Programmer World
programmerworld.co
-
sir...It us possible to locate car parking area using gps...How can we do this sir??
In my tutorial I have shown how to get the location using GPS and store it in your local phone.
For tracking, the other part is to send this information to some server and receive it on another device (smartphone). You can use Firebase database provided by Google for free. Otherwise you can have your custom servers where you can store your location details and read it from 2nd phone. I will try to make a video on this and publish it when I get time.
Good Luck!
Hello Master and greetings! I have a question: you may give me a example about how get location two devices movil in a maps? thanks.
Create the location tracking App as shown in this video. Then capture the latitude and longitude of the phone's location during live movement.
Then Transfer the latitude and longitude information through another App or SMS facility or store it in some database which can be accessed from another device. This part of concept is not shown in my video. We will try to do it if we get time.
I'm interested in this too !
@@lowjl6046 Hello,
You can refer to the below video in which I have shown how to send SMS pro-grammatically directly from your App.
ruclips.net/video/pajvuBZc2WA/видео.html
This concept can be used to send the the details of you location like latitude and longitude to another phone and a log can be created. Of course SMS charges can be applied by your service provider.
In the receiving phone, create an App which reads the SMS messages as shown in my below video:
ruclips.net/video/K9IloJ_66WI/видео.html
Once you have that data in another phone through SMS then plot those points on the Map. And voila, you will see the location of first phone in 2nd phone.
Good Luck!
I Wanna to get my order and customer place by cart item by customer
I think you are looking for an e-commerce App. Combinations of below App may help to create the App with different layouts (cart layout) and databases:
programmerworld.co/android/create-a-simple-business-app-using-sql-lite-database-in-android-studio-for-beginners/
programmerworld.co/android/how-to-develop-an-android-app-for-your-retail-business-b2c-using-firebase-database-source-code/
programmerworld.co/android/how-to-insert-floating-pop-up-window-layout-on-top-of-the-main-layout-in-your-android-app/
programmerworld.co/android/how-to-create-multiple-layouts-and-menu-items-in-your-android-app-switch-layout-and-exit-menu-options/
Cheers
Programmer World
programmerworld.co/
-
@@ProgrammerWorld thnx
which language it is ? java / kotlin ?
This is Java. If you want to convert the code to Kotlin then you can refer to the steps shown in my below video:
ruclips.net/video/6uaxKrvy-JE/видео.html
Cheers
Programmer World
programmerworld.co
-
If I want to buy this project can I?
Yes, you can.
Cheers
Programmer World
programmerworld.co
-
Hi thanks for your video. How to make it as tracking ETA not only location?
Will try to make a tutorial to show how to get ETA from your custom location App. Once created I will post the link here. Thanks!
Can I get a google API key if i dont have abilling account?
Yes, you can. You don't have to pay anything if you are using the maps for non-commercial purpose. So, google doesn't requires a billing account for the same. Steps for the same is shown in the initial part of this video tutorial.
Good Luck
Programmer World
programmerworld.co
-
How can you add a gps to any place such as airport or storeS?
GPS is global position system information provided by satellite (specific GPS satellites). So, it is almost available everywhere though signal may be a bit weak within buildings or basement.
Good Luck
Programmer World
programmerworld.co
-
@@ProgrammerWorld How can we add a background image of a map? Let's say a shopping map ? Can we overlap with a bitmap image? I thought it should be showing the gps, so that it can track our movement?
Yes, you can overlay other widgets, including imageview, on top of the map in the layout. My below video may help you in knowing how to add other widgets in the maps layout:
ruclips.net/video/Nsl99WWDFxM/видео.html
Good Luck
Programmer World
programmerworld.co
-
Which language based on this coding
Java
Hello sir can I use this code to locate my bike ??
Yes, it can be used to keep a track of your bike. Just fix a device in your bike which can transmit the location GPS to the tracker device.
You can use either SMS (offline) concept or Firebase database (online) concept to transfer the data. You can refer to the below pages for the same:
programmerworld.co/android/how-to-track-your-location-using-gps-and-send-it-over-sms-in-your-andoid-app-complete-source-code/
programmerworld.co/android/create-location-tracking-android-app-by-exchanging-location-information-over-firebase-database/
Good Luck
Programmer World
programmerworld.co
-
Hello, I realy like your videos, I have the same project but tracking GPS modules on a Bus using GSM to send the location of the Bus by the GPS by SMS to my Appication, Can you help me or at least refer me some good infos ?
As I have explained in one of my other comments that you can do this by storing the coordinates (Latitude and longitude) in a variable in your code. And then use the SMS service to send these values to the recipient. For this you will have to modify your manifest file in order to access the SMS service of the phone.
Due to my other engagements, I am not getting time to make this tutorial. If I make one I will let you know. I don't know if there is any other tutorial on similar concept. I am a freelancer programmer and does mostly independent development.
Thanks for your questions however.
same project. did you collect requirements for the project? like diagrams and APIs etc...
please must reply to me
thank you
can it track the location of other devices?
Yes, it can track other devices.
You can watch my below videos which shows detailed steps on passing the location information to another device:
ruclips.net/video/FknRti6n_F8/видео.html
ruclips.net/video/hyi4dLyPtpI/видео.html
Cheers
Programmer World
programmerworld.co
-
hi may i know what are the specific specs of the phone needed?
There is no specific requirement of the phone. Only thing you should ensure is that minimum API level selected in your phone is supported by your Android OS. For example: for API 26, Android 8.0 (Oreo) and above is needed as shown in my video at 1.01 min. Similarly, for API 21, Android 5.0 (Lollipop) and above is needed.
@@ProgrammerWorld sorry this is my first time creating this,i am still confused and I only have a budget for a phone that has 2gb ram, 16rom and kitkat android. will that be ok?
Hi Kyra,
For the location tracking App, you do not need very high specification phone. I think the phone specification which you have mentioned should suffice for this App. Regarding the OS, Android kitkat is Android version 4.4 which support minimum API level 19. So, please make sure that you select the API level 19 while creating your App in the Android Studio's initial setup page for the App. The only difference is that with each API level change some the commands and APIs is modified by google team. So, minor adaptation of code is required with the change in API level.
Moreover, if interested you can watch my 2nd version of location tracking App using the below link: ruclips.net/video/FknRti6n_F8/видео.html. This video also covers how you can send your location info automatically over SMS to another phone.
sir when i try to run this on my device the application is stopped showing on my device
Does it works on your emulator? If no, then can you please debug your code or send me a copy of your code and I will check?
If it is working in emulator and giving issues only in actual device then please check for permission of your App in the setting of your Android phone. Also please let me know the exact error message you are getting.
Cheers
Programmer World
programmerworld.co
-
Also complete source code shown in this tutorial is available at the below url:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
You may copy paste part of the codes in case needed.
Cheers
Programmer World
programmerworld.co
-
i am not geting current location in mobile when i installed it in my mobile
Please check whether your App has the permission to access the Location in your Phone. You can check this in your phone by going to Setting->Apps->Permission->Location Permissions.
If the location permissions are not provided please enable it. Also, there are 2 types of location access - Fine and Coarse location info.
Coarse uses only GPS data to get the location info so the location coordinates (latitude and longitude) may not be very precise.
Fine will use combination of GPS and Network data and will, hence, provide more precise and accurate location information of your phone. Both of these are explained in the source code provided in the below link:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
I will suggest you should use Fine location access which give you better and more precise location information.
Good Luck
Programmer World!
programmerworld.co
-
@@ProgrammerWorld yes it has permission
@@vaibhavpallod1023 Then it should work. There is no other reason for the App to not work. I assume that your map is showing up in the App. The other reason when it fails is if you have incorrect Google Maps API key registered in your App. But as long as your App is working on the emulator or the Map is showing up that possibility is ruled out.
Cheers
Programmer World!
programmerworld.co
-
Hi Sir, when the app is launched, it does not show me my location (Singapore), instead it gave me the location you shown in the video. May I know what must i change in order for the device to retrieve my location?
Are you running it on emulator?
For actual location, you need to run it on your real phone and ensure GPS satellite is accessible during the first run. (Be in open area).
Good Luck
Programmer World
programmerworld.co
-
Programmer World ah i see, thank you. can i ask if it is possible to add icons(for navigation to other pages) on the maps page ?
Of course it is possible. Just create your layouts and then use setconntentview to switch to that specific layout in Java code. You can add buttons as icons in main maps layout to call/trigger these commands.
Good Luck
Programmer World
programmerworld.co
-
Programmer World thanks for the information!
Programmer World Hi Sir, is it possible to track where my friends are through adding their phone number to the app?
Can anyone help me? Why does it shows my location in USA as I live in India??
Location shows USA because you are running the App on emulator. If you run it on your phone it will show precise location. In emulator, though there is gps and network options but those information are not available to emulator phone from your computer. So, emulator just imitates a pre-set location point on your map which is USA.
@@ProgrammerWorld Thankyou so much. It worked.
Bro.... this same it now 2020
I think overall the concept is still same. It should still work in 2020 also. Let me know if you have different observation.
Cheers
Programmer World
programmerworld.co
-
So good sir
hi please i can get the source code
Complete Source code is available on my website:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
Cheers
Programmer World
programmerworld.co
-
guys please help, my project consist of 2 users,admin and user,the need to know the location of the user,how can i implement this in my app!!my teachers suck!!
Hi Rahul,
In this video it shows the steps of how to fetch the position (latitude and longitude) of the user. Now, once you have the location information, you can pass it to the Admin using any channel such as through chat App, updating to a database such as Firebase or over SMS.
The steps to send the location info over SMS is shown in below link:
ruclips.net/video/FknRti6n_F8/видео.html
The steps to create a chat App with End to end encryption is shown in below link:
ruclips.net/video/bVXT_AkHIEQ/видео.html
The steps to create a Firebase database is shown in below link:
ruclips.net/video/52pQU6S66S0/видео.html
Hope the above are useful.
R.Id is coming error
Please help me
Just check if the Objects are created in the layout XML file. If an ID is assigned to any object/ widget in the layout file then it will be accessible through R.id.....
If the object is already defined and still not appearing in the R.id then restart the Android studio and check. Sometime restarting IDE also solves this kind of issues.
Good Luck
Programmer World
programmerworld.co
-
Marker is not showing on map please help me!
Hi,
I hope you have given location access permission in the manifest file. Also, I hope following lines of code have been added in your java code to seek permission from your user for the location access.
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PackageManager.PERMISSION_GRANTED);
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, PackageManager.PERMISSION_GRANTED);
If above is done, then please check you have got the access to the location system service using below code in your method:
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Lastly, you should ensure that you are using Map.moveCamera method call to move the map so that your marker is visible and map points to the correct location.
If all the above looks good to you, then please share your code here and I will try to debug it check it.
Good Luck!
Programmer World
@@ProgrammerWorld same problem is for me
Will it be possible to share your code? I can have a look.
@@ProgrammerWorld I wrote code as you written..
If the code is exactly the same then it should work. If I could have got your code then I could have debugged and verified the same. I hope you have tried it on both emulator and smartphone. Also, I hope you have checked if Internet connection is available on your device.
Bro can i store this location in firebase
Please watch my below video for the same:
ruclips.net/video/hyi4dLyPtpI/видео.html
Good Luck
Programmer World
programmerworld.co
-
hi bro this application can be used to track the Freight Transport ?
Yes, sure. You should watch my next version of tutorial at below link to know how to do it:
ruclips.net/video/FknRti6n_F8/видео.html
One other approach for your use case could be to keep storing the current location information in some sort of database (say Firebase) and the broad cast the location info (latitude and longitude) from the database to all the receiver stations or Apps.
Programmer World hey , i’m not very good in programming mostly android so I will try to follow the next version tutorial if it is to track down ! (my project is making an application to know the carrier's location)
Not working on device
Is it giving any error? OR is the App crashing?
I hope all the required permissions, such as location and internet, is declared in the manifest file.
Cheers
Programmer World
programmerworld.co/
-
@@ProgrammerWorld its not displaying any locations on the map.
Where's part 2 of this series?
I think you should watch my below videos which shows further concepts in this series:
Location tracking by exchanging location information over Firebase database:
ruclips.net/video/hyi4dLyPtpI/видео.html
Track location in offline mode and send it over SMS:
ruclips.net/video/FknRti6n_F8/видео.html
Convert Latitude and Longitude to an actual address on the map:
ruclips.net/video/Nsl99WWDFxM/видео.html
Good Luck
Programmer World
programmerworld.co
-
@@ProgrammerWorld Thanks for sharing. I will do that.
Hey buddy I need tracking device to locate and lock the access of my app
One can use the concept shown in this video to track the device and lock the device remotely from the App.
The source code for these concepts is available in the below links:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
programmerworld.co/android/create-location-tracking-android-app-by-exchanging-location-information-over-firebase-database/
Good Luck
Programmer World
programmerworld.co
-
Hey buddy can I use the same code to locate my bike ???
I want to get the crime record of the particulation location how can we code that for particular location so that we can get the crime record of that location
@@ayushisinghal553 For your requirement, the crime record for the locations should be stored in a database. Then that database values should be accessed and plotted on the map. Something similar to what is shown in the below link:
ruclips.net/video/hyi4dLyPtpI/видео.html
Cheers
Programmer World
programmerworld.co
-
What is the api link
Hi,
From API link, if you referring to Google Maps API key, then it is the link to the encryption key used to sign the APK for Google Maps based APIs. Also, You need a different API key for each encryption key, including the release key that is used to sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
I hope the above answers your query. However, if you meant something else then please let me know. Also, the complete source of this tutorial can be found in the below link:
programmerworld.co/android/design-a-location-tracking-app-using-gps-in-android-studio/
Good Luck
programmerworld.co/