locationmanager

Android - Trouble in getting location coordinates by only using GPS provider

风格不统一 提交于 2019-12-06 08:44:33
问题 I am new to android. So please apologize if my question is simple and help me. I am developing an android app in which I try to get users location only using GPS service (As I am developing an app which needs to run in android devices even with no internet ). My code is given below: My activity: public class MyView extends Activity implements OnClickListener, Runnable { LocationManager itsLocationManager; LocationListener itsLocationListener; @Override protected void onCreate(Bundle

Android: how to find total distance covered using GPS when continuously moving?

与世无争的帅哥 提交于 2019-12-06 08:34:06
问题 This is my code. Please tell me y it is not able to calculate the distance.. In this code res is a long variable which is supposed to store the total distance covered. This code is supposed to calculate distance based on GPS as soon as there is a change in the latitude and longitude.. String serviceString = Context.LOCATION_SERVICE; LocationManager locationManager; locationManager= (LocationManager)getSystemService(serviceString); String provider = LocationManager.GPS_PROVIDER; final Location

Android: how to set a proximity alert to fire only when exiting or only when entering the location

微笑、不失礼 提交于 2019-12-06 07:01:50
问题 I am developing a ToDo app with reminders(by time and by location) and the thing is I give the user the option to choose if he wants the reminder by location to alert when he is entering the location or when he exits the location. how can i do that?? I know about the KEY_PROXIMITY_ENTERING but I dont know how to use it Please help... thanx in advance 回答1: The KEY_PROXIMITY_ENTERING is usually used to determine whether the device is entering or exiting. You should first register to the

Android - Location by LocationManager different from GoogleMaps

南笙酒味 提交于 2019-12-06 06:38:42
I have created a location listener by 'LocationManager' with this code: mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 100, 100, mListenerNetwork); and the listener: LocationListener mListenerNetwork = new LocationListener() { public void onLocationChanged(Location location) { // New Location by LocationManager } public void onProviderDisabled(String provider) { } public void onProviderEnabled(String provider) { } public void onStatusChanged(String provider, int status, Bundle extras) { } } And I have a listener by google maps API: getMap()

Notify users when they reach a location

蹲街弑〆低调 提交于 2019-12-05 19:46:56
In the application I'm working on, one of the features is to notify the user when they reach a location that they have set prior. The code below is in addProximityAlert in Activity: final Intent intent = new Intent(PROX_ALERT_INTENT); final PendingIntent pendingIntent = PendingIntent.getBroadcast( InfoActivity.this, 0, intent, PendingIntent.FLAG_ONE_SHOT); LocationManager locationManager = (LocationManager) this .getSystemService(Context.LOCATION_SERVICE); locationManager.addProximityAlert(18.7726271, 98.9738381, 5000, -1, pendingIntent); this.locationReminderReceiver = new

Android LocationManager network provider returns null

泄露秘密 提交于 2019-12-05 18:02:49
I wanted to get my GPS coordinates using Android App. I started developing, and I can get GPS coordinates, but they are not accurate. I wanted to use NETWORK_PROVIDER, but the Location by this provider is always null. More interesting, isProvicerEnabled returns true. I used example from this thread (best answer) enter link description here private void _getLocation() { // Get the location manager try { boolean isGPSEnabled = false; boolean isNetworkEnabled = false; locationManager = (LocationManager) getApplicationContext().getSystemService(LOCATION_SERVICE); Location location = null; double

LocationManager.requestLocationUpdates add or update?

孤街浪徒 提交于 2019-12-05 18:00:50
I am looking at LocationManager to get best location for periodical reporting location. I am curious about LocationManager.requestLocationUpdates method. What would it happen if I invoke this method several times with different minTime and minDistance without calling removeUpdates? Will it add new request or just update the existing one? I am trying to test this, it is not bit easy at the moment. Your answer would be appreciated. It will update the existing request. You could register it multiple times. see my code below. package com.test.locationmanager; import android.app.Activity; import

LocationManager requestLocationUpdates doesn't work

雨燕双飞 提交于 2019-12-05 11:07:55
I'm trying to get the current location in android using LocationManager and LocationListener as described at http://developer.android.com/guide/topics/location/obtaining-user-location.html However, onLocationChanged method of the LocationListener is never called. I've used a real android phone / also used the emulator and simulated location changed using telnet, as described in the link above. Here's my code: public class MyActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); /* Use the

What's location provider “passive”? Seen on HTC Desire with Android 2.2

我怕爱的太早我们不能终老 提交于 2019-12-05 06:33:03
Before I go into location based mode I check for existence of any location providers by calling List<String> android.location.LocationManager.getProviders(boolean enabledOnly) //enabledOnly = true and checking the size of the resulting list. Now I tested my App on a HTC Desire with Android 2.2. The system settings don't allow any location tracking (GPS and mobile is turned off). However, the list get returned has 1 entry, whose value is "passive". What is it? Can I work with it? The provider seems to be slow / not working. From the Android API reference : A special location provider for

Android: LocationManager constructor's looper

给你一囗甜甜゛ 提交于 2019-12-05 05:41:38
问题 There is the possibility to start retrieving notifications from a LocationManager with the following method: requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener, Looper looper) Documentation explains attributes with these words: provider the name of the provider with which to register minTime minimum time interval between location updates, in milliseconds minDistance minimum distance between location updates, in meters listener a LocationListener