Tag: location

How to get speed in android app using Location or accelerometer or some other way

I am working on app and try to get the speed and distance travelled by the user. I have used Google Play services location class to get the speed but it always returns me 0.0 value and not at all reliable. I wan accurate speed and distance travelled at real time. I have installed GPS […]

onConnected() not being called to get location updates (GooglePlayApi for location)

So i have this code: package com.entu.bocterapp; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.os.Bundle; import android.widget.Toast; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GooglePlayServicesUtil; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; public class LocationManager implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { private Context mContext; private GoogleApiClient mGoogleApiClient; private Location mLastLocation; private LocationRequest mLocationRequest; public LocationManager(Context context) { mContext = context; // if […]

LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this); Tries to cast as com.google.android.gms.location.LocationListener)

I have set up a Location based map on Android however when I try and call: LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this); Android studio tries to have me cast it as LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, (com.google.android.gms.location.LocationListener) this); This however causes the app to crash when it is called. I have the following Location code for my app: import android.content.IntentSender; import android.location.Location; import […]

Use mock location without setting it in settings

I am writing an App which makes use of the location mocking possibility in android. What I would like to achive is to mock my location without setting the “allow mock locations” flag in the developer options. I know that it is possible, because is works with this app: https://play.google.com/store/apps/details?id=com.lexa.fakegps&hl=en What I tried: Generate an […]

Android Context without being in an activity? And other activity-less programming?

I’ll try really hard to turn this into one comprehensive question: I’m writing a method to get a String that contains the name of an Android device’s city, as determined by the LocationManager and getLastKnownLocation() and all that. Then I realized I’d need to do the same thing again in another activity, so why not […]

What is the meaning of android.location.LocationManager.PASSIVE_PROVIDER?

I understand the meaning of GPS_PROVIDER (locations come from GPS signals) and NETWORK_PROVIDER (locations are determined from cell towers and wireless access points), but I don’t understand the meaning of PASSIVE_PROVIDER, despite the definition in the API: A special location provider for receiving locations without actually initiating a location fix. This provider can be used […]

DDMS not able to send location to emulator

DDMS is not able to send location to the emulator. I have tried sending just the location from DDMS but still the emulator is not able to receive location. The application works properly in the device but its not able to capture location data in the emulator. I am testing on Android 2.2 emulator. Can […]

requestLocationUpdates interval in Android

I try to get the correct speed in updates for the function onLocationChanged, this is my class: public class LocationService extends Service implements LocationListener { Putting the minTime on 6000 does not help, it wil keep updating constantly, what am i doing wrong? public void requestLocationUpdates (String provider, long minTime, float minDistance, LocationListener listener, Looper […]

is it possible to get distance between current location and a street, avenue or area?

all solutions about calculating distance are between two points. my question is: Is there any way to calculate the distance to a certain street? suppose I want to calculate a distance from my location to a specific area or avenue, which have many streets to get there, in this case how to know the nearest […]

Location Updating on basis of device state

I need to get location(By fusedlocation API) of user after ActivityRecognition Detect user state (Which calls every 3 mins), like IN_VEHICLE,ON_FOOT,RUNNING etc. On each event i need user location after regular interval For example: if user is still then setInterval(5*60*60*1000); and check for next location update in not before 5 hour. But ActivityRecognation Will call […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.