EDIT: As Francky Vincent said, I see that price depending on distance is not advisable. I have 4 parts but only 3 are the prices depending heavily on the distance (and planning to change it later). But, I still need to get current location as I have 'x.x KM from you'.
A little bit of intro:
When I was around somewhere with low coverage, I open the Grab app and able to get my current location, even though will take too much time. My own app have no problem with location but at the same location, it will get the last known location - and I don't want that since one of my app feature is the price is according to the distance between current location and target.
For the codes, I just using the examples provided for Fused Location by Google in Github and seems like it's not enough? My aim is to get current location instead of last known - just like the Grab app.
Is that possible using Fused Location? Or did the example provided can achieve what I want but I missed something important?
I referred to this question but still got clueless. Really new with this feature.
The strategies that I can come up is:
Start app
Check permission
Request permission
Get current location
Save the latitude and longitude in SharedPreference
Stop getting location
Please help. Thank you!
Related
I've searched online but haven't yet found anything like this. Basically, is there a way where I can know if I'm facing a certain location.
For example, I have my current location in latitude & longitude and I have a second location in latitude & longitude. Now I want to know when the second location is directly in front of me as I turn.
I'm going to assume that you mean the phone is "facing" the location of interest, and you already know which axis will determine this. What I would do is use the SensorManager.getOrientation(float\[\], float\[\]) to get the radians of where you device is facing, then convert it into degrees.
Next, I would ensure I get an accurate and current point from the device (GPS, not Network), and call Location.bearingTo(Location) on the location from the device with the destination location as the parameter to get the degrees to it.
Finally, I would compare the two results and determine if the device is "facing", within a certain range. This might have to be adjusted based on how far the destination is from the current location, but I would experiment with this a bit.
You can predict your direction/location if you use Android location Manager. Take a look at this example
I don't know if this help, but you could take a look at the Places API from Google: https://developers.google.com/maps/documentation/javascript/places#place_search_responses
The response has an attribute called viewport that with some processing can help you
I don't need to be too precise. I want to know location can be an area of the user in one country. I tried using the location service getLastKnownLocation with the update through GPS. If the getLastKnownLocation is unknown, the time it take to get the result is quite a bit of time. I am working on the weather application, I don't need to have the street name. Is there another way of getting the result more faster.
you can get the last known location for more detail read here last Known Location
or you can request a location updates every period of times you set request locaion updates
it's pretty straightforward
I'm using indoorAtlas SDK. I already succed to show current location and floorplan using indoorAtlas. But it has some weird result.
If i'm inside building that i listed the floorplanid and venue id, it gives the correct current location. But when i'm outside that building and i'm trying to locate current location it gives the result in the floorplan map but it gives some random location.
Is there any way to give some notification or action that i'm outside in area that i'm listed floorplanid and venueid ?
In current SDK there is nothing that would give you straight answer to your question. I'd say that your best tools at the moment are the getUncertainty() -method in returned location update (ServiceState -class) combined with platform locations. Experiment with uncertainty value (radius in meters) to see when it would be best to start trusting platform locations over IndoorAtlas's indoor locations and to conclude that user has exited the building. In a more advanced version, when moving towards the edges of your floor plan (or better yet towards the exits) you could be more sure that transition (in->out, out->in) is likely to take place.
You could also combine this logic with geofences (http://developer.android.com/reference/com/google/android/gms/location/GeofencingApi.html) in one or more ways. E.g. use geofence as an indication that IndoorAtlas services should be turned on as user may enter a building and when entered, dynamically create a larger geofence as a safeguard to help your algorithm to detect that user has exited building and IndoorAtlas service can be turned off.
Hope this helps to find your solution.
I've ran into a little problem and I don't feel like I'm informed enough to overcome the hurdle.
In essence, I'd like to figure out whether someone is moving over a threshold of say, 40 kmh (~25mph). I get GPS coordinates at designated intervals and compare the distances, which all works fine.
My question is, which method of getting GPS coordinates would work best for this application? Using the Network, using GPS, or both (like, check if the network is connected, else use GPS)?
The summary is, which is the most accurate method?
I'd use the fused location api in this case. In addition, if you want to know if someone is moving you could use the activity recognition of google play services, it requires much less effort and you can even filter by activity: only with car for example (if you want to track over the 40km/h it's unlikely someone is moving on feet).
Would it be possible to make an Android application that works based on location, for example when you get to work the app might turn off WiFi or Bluetooth or change any other system settings in order to save battery or something?
The app would require the user to enter in locations where they want the app to begin working, like their address, and when the phone sees that they have arrived at this location it will start working. I want to do this but I don't know where to start.
I already have some android app development experience.
Yes absolutely this is possible. I have worked on approx three application with same concept.
You need to create a center point and define a radius for the same.
Then you need to calculate the distance of you current location with that particular center point and if your distance is less than or equal to radius, trigger to switch on the services you want.
In android you can use
LocationManager class
For collecting the data. If you want some more help I can provide the same too.
I've played around with a concept like this on the Windows Phone for a while, and I think this would work for Android too.
Basically, you'd use the GPS of the device to detect your location, and then compare this to the locations saved by the user. If the location comes within range of a saved setting, perform an action.
GPS usage however drains battery, so you'd have to experiment a bit with making this an efficient method.
Have you tried GeoFencing, its really cool. It lets you define a center point, and a radius. Once the user enters this radius you get callback or a pendingIntent. You can do what you want in your callback.
You can get addresses of your customers and build geofence around their locations.
Edit :
If you choose to not use GeoFenceing (for what ever reason), note that LocationManager is highly buggy and unstable on most mobile phones (Samsung).
Instead use LocationClient, which takes care of all the crap LocationManager leaves with us to deal with and provides location faster, lesser battery and customized accuracy.
Edit :
If anyone tries to convince you otherwise, check this out. A video from google developers and their talk about why LocationManager sucks, and why they knew and helped us figure out the value Sensors add to the entire solution.
Edit : Design of your solution
You need 2 geofences
1) Outer, you can hard code this to a imaginary 500 m from office. From then on you can start looking for wifizones
2) Once a wifizone is found, save the gps and the distance from his address point. That is your inner radius.
1 Geofence is defined by your install, 2nd geofence is defined by your runtime.
2nd Geofence and be used henceforth to disable GPS (only incase you decide to use LocationManager). If not you wont need this, LocationClient will do what it does best.