Android GPS Location Without Internet

Posted on 2013-08-28
Medium Priority
Last Modified: 2013-09-17
I want to develop an Application which will store the Longitude and Latitude of
an Android device into device internal database, Using Device's GPS Chip and Not using Internet at all.

Can some one provide me the source code for the same.
Question by:shahjagat
  • 2
  • 2

Expert Comment

ID: 39444928
Hello shahjagat,

While I won't provide you with a fully functional example application, I can show you some useful links that you could use in order to achieve your goal:

- Here is how to create a database for your android application
- Here is how to get your GPS coordinates

Now you should be able to do your application just by combining those two pieces of information (creating your own DB application + getting your GPS coordinates + saving your coordinates into your database). As you can see, it doesn't implies using internet connection at all.

Good luck!
LVL 17

Expert Comment

by:Chris Harte
ID: 39445429
In the tutorial on gps replace the line

provider = locationManager.getBestProvider(criteria, false);


provider = LocationManager.GPS_PROVIDER;

This will force the activity to use gps rather than network. In my experience android always defaults to 'network' even when there is no network connectivity.

Author Comment

ID: 39445632
Thanks Argenti,


I am new android developer

I am using below code, but it does not return latitude and longitude when internet is OFF,
I also want to calculate speed, distance covered and odometer reading ,
My device will be inside the bus and in the region where there is no internet.

Any help will be appreciated,  

My code
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,MIN_TIME_BW_UPDATES,MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
if (locationManager != null)
             location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
            if (location != null) {
                  latitude = location.getLatitude();
                  longitude = location.getLongitude();
LVL 17

Accepted Solution

Chris Harte earned 1000 total points
ID: 39446413
That is only part of your code and looks okay. Getting a signal from a satellite can be slow. Also, are you running this on an emulator or your device? Because the emulator does not get a satellite signal.

Author Closing Comment

ID: 39499005
Thanks for all answers

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This article shows how to use a free utility called 'Parkdale' to easily test the performance and benchmark any Hard Drive(s) installed in your computer. We also look at RAM Disks and their speed comparisons.
Creating a Cordova application which allow user to save to/load from his Dropbox account the application database.
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question