I try to receive latitude & longitude on android phone.
Is location on android receive directly from satellite?
Why it dynamic all the time, while I standing though?
So, anyone know how to make it stable ?
Thanks
The location may come from a variety of places:
The "last-known" location, an OS-level cached location (fast, but may be inaccurate)
The wifi network (Google can often deduce location from the wifi net you're on, but not always)
Mobile network - if the device is on a mobile phone network, that can provide location information
GPS receiver. If the device is outdoors this will provide the most accurate location
Your app will have specific needs, and so you need to decide which locations you want, and what you do when you get them, based on their accuracy, and the source.
With GPS, buildings, tees, the weather, etc will all have an effect on the location, so you'll never get one amazingly accurate location. Many apps just request a location and use it, but if you need accurate, stable location data, you need to collect data from relevant sources, and then use your own algorithm to decide which to use.
You need to read, understand, and use what's in this page:
http://developer.android.com/guide/topics/location/obtaining-user-location.html
Related
I have a mobile app (iOS and Android) that pings the location ~ every 15 seconds and is used in urban areas.
From my understanding
If Wi-Fi is disabled the app will use just GPS for location
If Wi-Fi is enabled the app will either use a mixture of Wi-Fi and GPS or just Wi-Fi
Generally Wi-Fi on drains more battery however if you are tracking location then it might actually save battery since GPS is more battery intensive than Wi-Fi (I think!)
Does anyone have data if enabling (but not connecting to) Wi-Fi will be better or worse for battery life?
Enabling WiFi should be good for battery life, but it depends entirely on how your application is coded. If you take a look at Android's page on Location Strategies, it says: 'GPS, Cell-ID, and Wi-Fi can each provide a clue to users location. Determining which to use and trust is a matter of trade-offs in accuracy, speed, and battery-efficiency.'
It is possible to get the location from just WiFi (yes, unconnected!):
netLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
but this may not be the most accurate solution. GPS uses a fair amount of power, but is obviously more accurate than WiFi, and searching for unconnected WiFi hotspots also takes power. In other words, this is a very complicated question.
All in all, the best solution (to avoid spending all your time coding this location stuff) is just to integrate Google Play services into your app. You can then specify the priority of finding the location (power or accuracy) and Google will sort it for you (check this out or the official google docs here).
protected void createLocationRequest() {
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(15000);
mLocationRequest.setFastestInterval(5000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
protected void startLocationUpdates() {
LocationServices.FusedLocationApi.requestLocationUpdates(
mGoogleApiClient, mLocationRequest, this);
}
#Override
public void onLocationChanged(Location location) {
mLastLocation = location;
}
The other priorities are PRIORITY_BALANCED_POWER_ACCURACY, PRIORITY_LOW_POWER, PRIORITY_NO_POWER.
However, back to the question. If we look again at Android's page on Location Strategies and scroll down, it says: 'Depending on the environment where your application is used or the desired level of accuracy, you might choose to use only the Network Location Provider or only GPS, instead of both. Interacting with only one of the services reduces battery usage at a potential cost of accuracy.'
From this, we can draw that using both WiFi and GPS gives a more accurate location than using just one, but that using just one uses less power than using both. HOWEVER, this depends on the environment. Since your app is designed for use in URBAN environments, it is often harder to get GPS signals (due to buildings). But getting a location from WiFi alone does not work all of the time (even in urban environments). However, for your app, since it is used in URBAN environments, I believe that using WiFi AND GPS will be the most power-efficient option for you, because sometimes GPS may not be available or will take a long time to connect (in urban environments). Remember, in urban environments people may lose GPS (e.g. they go into a store or into a very narrow alleyway). But if you have WiFi, you'll hopefully still be able to have their location. Another possible option to think about is trying to get their location using WiFi only at first, and then try GPS only if you can't get their location using WiFi. But this depends on how accurate you need their location. All in all, just leave it to Google (as shown above).
In answer to your question, it depends on how you're finding the user's location. I've suggested how to code your app, but if you want to leave it as it is, please post or comment the code you are using the find the user's location so that it can be determined which option is more efficient.
EDIT: I've seen that this is about iOS as well as Android. iOS provides much less control over how the location is determined. You just plug in the desired accuracy and Apple do the rest. Apple will determine the most power-efficient way of getting the location, and the same stuff that I've written above applies. Anyway, Apple will prompt users to turn on WiFi if it is disabled when getting the location, so trying to prevent use of WiFi for location on iOS is pretty much impossible.
GPS power consumption is extremely high compared to WiFi. Most phone lasts less than 10 hours on GPS while with WiFi they can last more than day.
WiFi is not only for location or the internet, it has multiple uses,
if you are using older os than Marshmallow, you can't disable all functionality to use WiFi while it is on.
from Marshmallow you can enable it for the specific use like location only.
so it will consume less power than GPS.
while in the prior version, GPS is in winning condition in power consumption.
https://android.stackexchange.com/a/127571/116948
I don't have any hardcore data on the subject, and doubt anybody will have any concrete numbers, but theoretically Wi-Fi will be far better than GPS only. The theory works something like the following: In order for a GPS to know where someone is at, it needs to receive information from 3 different objects at known locations and use triangulation to figure out its location from that, whereas wifi only needs to make one call, to the nearest internet repeater, which has a known location and known path. In order to assure accuracy this is often done multiple times with each location request. Thus the extra calls add up and Wifi will be more efficient.
Use WiFi whenever you have access to a network because it uses less battery than GPS. (Shorter distance, lower power.) Turn WiFi off when you don't have access to a network, otherwise it will keep looking for a WiFi network it can use (which drains battery).
I am trying to design an app which requires current location of the user time and again. So, whenever cellular data is available, i use mobile network to get the current user location. If mobile network is not available, can I reliably use GPS to get access to current location. If not, can anyone suggest what should I do in such cases?
Edit: Location services doesn't work very well. I already tried using it.
I think you should take a look at Android Location APIs:
https://developer.android.com/google/play-services/location.html
Android uses what they call Fused location provider. It is Android (through Google play services) responsability to choose which provider (GPS, sensors, WIFI fingerprinting...) is best each time to get current user location.
I think it is a great technology and APIs are really simple to use
According to Google Docs:
Knowing where the user is allows your application to be smarter and deliver better information to the user. When developing a location-aware application for Android, you can utilize GPS and Android's Network Location Provider to acquire the user location. Although GPS is most accurate, it only works outdoors, it quickly consumes battery power, and doesn't return the location as quickly as users want. Android's Network Location Provider determines user location using cell tower and Wi-Fi signals, providing location information in a way that works indoors and outdoors, responds faster, and uses less battery power. To obtain the user location in your application, you can use both GPS and the Network Location Provider, or just one.
If you want more detail you can take a look at :
http://developer.android.com/guide/topics/location/strategies.html
yes If there is no Network available then you can go for GPS but we must use it smartly and efficiently
because GPS give much accurate location than network, but it reduce the battery life and also you can use Pending Intent for getting location and broadcast receiver at the place of Location Listener
but I suggest you this link with light this topic in much detail
These are some smart coding concepts for increasing battery life
I want to know if gps can be used to get the latitude and longitude of an address.I've just began to work on gps on android.My problem is that if the user does not have internet connection, i want him to be able to get the latitude and longitude of an address.Can gps do that or it is only used to get current location.If not are they any other way of getting this done.I;m using google maps and i've also tried to get geocoding as mentioned in some posts,but it does not work.
From your question,
If you are using Google Map and GeoCoder class that means you must have Internet connection. And moreover when you are working with GPS, again you must have Internet Connection. If you are using GPS_PROVIDER then you required open sky type environment and for NETWORK_PROVIDER you can fetch gps details inside a room,but for both provider Internet is must.
You are missing the point of what GPS is designed to do.
Your phone's GPS doesn't do anything with an address. All GPS does is get the latitude/longitude of your current position, nothing more. The phone (via an internet connection) is able to identify your address based on the Latitude/Longitude that the GPS provides by using 3rd party provides (such as Google Maps)
It sounds like you just want to get the latitude/longitude of any address, not just for the device's physical location. That does not require GPS at all. But it needs an internet connection in order to access a provider to perform the geocoding.
A answer I provided to Does GPS require Internet? is a somewhat related to your issue. The 2nd to last paragraphs are pertinent here as well
While it requires a significant amount of effort, you can write your own tool to do the reverse geocoding, but you still need to be able to house the data somewhere as the amount of data required to do this is far more you can store on a phone, which means you still need an internet connection to do it. If you think of tools like Garmin GPS Navigation units, they do store the data locally, so it is possible, but you will need to optimize it for maximum storage and would probably need more than is generally available in a phone.
So effectively, you theoretically could write your own tool, cache data locally and query it as needed, but that not something that is easily done.
I have make an android application which help us to get GPS Location using A-gps in my android phone. I am getting latitude and longitude successfully in Metro Cities of my country, but when I am going to some forest area,GPS do not get location and for this I need to run GPRS of my phone,after running google map once in my phone ,GPS successfully gets latitude and longitude even if I closes my internet connection or remove sim card from my phone. But since I do not want to use google map, what should I do now and why it is happening?? Any help will be appreciable
It takes a long time (several minutes) to get the GPS location with high precision. However, if you enable network based location (e.g. cell tower, WiFi), it's way faster but with lower precision.
As a result, you should listen to all the providers with LocationManager, and figure out which provides the best location. Or, if your app targets Android 8 and above, you can use the Location APIs provided with Google Play Services, which hides the details as using LocationManager directly.
First make sure that it is not the fault of your phone or its operation system version.
Download a well working known GPS App, look if they get a GPS signal without internet.
Place it under very good cointions: free view to sky, outside dense city, at least an open place.
You should get a signal within one minute, maybe if the phone has a poor built-in GPS antenna, a bit more, wait some minutes.
If the well working foreign app still don't get GPS it's an Operating system bug.
If you get one, then it´s your fault, and it is worth for further investigation.
*first check your GPS working or not properly with **ANDROITS GPS TEST*.
if it finds and fixes satellite do not worry. as AGPS is fast , standlone GPS needs to have much more time to fix on its own especially in city as many radio waves disturbs GPS fixure.
better first fix with AGPS and then you can turn off data or internet, still it will work as it already had its location and satellites fixed.
with standlone GPS it takes huge time and battery.**
If your phone use GPS h/w to get the location information, it don't require any internet connection. It should be able to get the location fix using GPS without the help of internet. But it may take some time to get the location fix.
You can install the this free app from play-store to test the GPS of your phone : "TestYourGPS".
https://play.google.com/store/apps/details?id=com.eorsavik.testyourgps
I'm working in android (developing application for mobile and tablets). I am using android version is 2.2.
In my application, I want to capture the longtitude,latitude.
My suprevisor is said to me capture the locations using GPS,AGPS,LBS
I'm new to android .I does not know GPS,AGPS,LBS.
Please send me the details, what are the difference,advantages,disadvantages of these 3?
Don't compare LBS with GPS and AGPS. LBS stands for Location based services . It's a service done with the help of GPS/AGPS . For example 'Requesting the nearest business or service, such as an ATM or restaurant' is a service required by a user. There are many applications available for to provide above service. Those application will use either GPS/AGPS to find the location and service to user based on the location fetched.
So simply any application which use location to serve users are considered as LBS.
Following is the difference between GPS and AGPS
The difference between GPS and A-GPS is actually pretty straightforward. A GPS phone comes with a built-in GPS chip. GPS, short for Global Positioning System, is typically used to determine the location, speed, direction and time of the device. So, for example, in the case of the Mobile, when GPS is activated on the unit, the system would be able to triangulate the position of the receiver when three or more satellites are connected. And since it is able to calculate speed and direction, GPS is also commonly used as a navigation device while driving.
A-GPS (Assisted-GPS), on the other hand, was developed to enhance the performance of GPS. This is especially useful in environments where the GPS chip may have difficulty in getting a satellite signal, such as an urban canyon, or places where there is too much overhead obstruction. What A-GPS does is it leverages on an intermediary called an Assistant Server which provides information on cell ID or other data to help the device identify the right satellites to connect to. This shortens the time needed for a location lock although certain A-GPS solutions require an active connection to a cell phone network.
Pros and Cons of GPS and AGPS:
The realiability and Accuracy is high in the GPS and it is low in AGPS.
The location captured by AGPS is not as accurate as GPS.
The location capturing via GPS is time consuming and power (Battery) consuming, etc.
Hope it helps. For more details on A-GPS
GPS - Global positioning system -> get your location via satellites
AGPS - Assisted GPS -> get your location via satellites and network providers
LBS - Location Based Services -> doesn't have much to do with getting your location.
Basically, in Android you can get your location using following providers:
Network: get your location based on your wifi connection. fairly fast, but not so accurate
GPS: get your location based on GPS receiver. fairly slow, but quite accurate
so you have a trade-off: either to use Network provider and get your results fast, or to use GPS provider and get more accurate data.
Read more here:
http://developer.android.com/guide/topics/location/strategies.html
LBS - Location Based Services
GPS - Global Positioning System
AGPS - Assisted Global Positioning System
LBS
As abbas.aniefa said, We can't say differences of LBS over GPS and AGPS. It is the service which uses GPS/AGPS to find location. Android provides a number of building blocks for location based services.
GPS
GPS, the Global Positioning System run by the United States Military.
This provider determines location using satellites.
Depending on conditions, this provider may take a while to return a location fix.
Advantages
It will give our location accurately,
It will work fine in out-door locations.
Disadvantages
It may be very very slow in in-door locations,
It will quickly drain battery.
It will be slower than network provider.
A-GPS
A-GPS - Assited GPS. Normal GPS can take a long time to get a position fix. For this reason most cell phone companies have the GPS in the phone turned off except for emergency calls and for services they sell you (such as directions).
A-GPS will come under network location provider category because it uses GPS chip on device, as well as assistance from the network (cellular network) to provide a fast initial fix.
Advantages
It will give our location very accurately in-door location itself,
Drainage of battery will be saved,
It will be faster than GPS Provider.
Disadvantage
We can not use it with GPS alone. It will depend on network connection.
Over all Differences of GPS and A-GPS
GPS
Uses GPS chip on the device,
Line of sight to the satellites,
Need about 7 to get a fix,
Takes a long time to get a fix,
Doesn’t work around tall buildings.
A-GPS
Uses GPS chip on device, as well as assistance from the network (cellular network) to provide a fast initial fix,
Very low power consumption,
Very accurate,
Works without any line of sight to the sky,
Depends on carrier and phone supporting this (even if phone supports it, and network does not then this does not work).
I think GPS is done/processed via satellite communication without any network service provider.
The AGPS is done/processed via the network (which is provided by service provider such as Airtel,Vodafone,etc).We should pay for service provider for usage of network.
The LBS is processed through the AGPS.
I dont know whether my points are correct or not.Im heard from others and put it.
All are welcome to give their suggestions,ideas,etc.