locationlistener

onLocationChanged callback is made on what thread? The main UI thread?

你说的曾经没有我的故事 提交于 2019-12-23 07:58:35
问题 When this callback is made in my app, I have quite a bit work to do (reading & writing to SQL db through an ORM lib and a number of distance based calculations). Naturally I am concerned about not blocking the main UI thread so I've been trying (unsuccessfully) to find out if this is the thread on which the callback is made. If it is, I'm intending to do all the afore-mentioned work on an AsyncTask triggered when the callback is made. This same AsyncTask will receive events from 2 separate

LocationListener timeout

喜夏-厌秋 提交于 2019-12-21 21:28:17
问题 I am currently using a timer to determine if a location listener has timed out ? The problem is that the gps remains on. I don't know why , is there a method i can override when the locationlistener times out or a more elegant method ? 回答1: Consider adding a GPS status listener to your location manager. The status listener is informed when the GPS starts, stops, receives a first fix, or the satellite status (no. of visible satellites, you need at least 4 for a fix) changes. The listener may

BroadcastReceiver for location

北城余情 提交于 2019-12-17 04:57:22
问题 I know BroadcastReceiver watches for text, phone events, etc... but can you run LocationServices as a service and event based on Location? For example, you are near a certain GPS point and the phone notifies you. 回答1: I think what you are looking for is something like this. There is a version of LocationManager.requestLocationUpdates() that takes a PendingIntent as a parameter, and this Intent could be used to fire a BroadcastReceiver . This code will register a custom broadcast to fire with

Getting Latitude and longitude in 30 seconds

别说谁变了你拦得住时间么 提交于 2019-12-17 02:32:55
问题 I am trying to get location of user as longitude and latitude from GPS/network which ever is available and i want to get it fast , or else previous location coordinates will return if cannot get new one right now. Here is my attempt: public class GPSTracker extends Service{ // The minimum distance to change Updates in meters private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters // The minimum time between updates in milliseconds private static final long MIN_TIME_BW

Tracking user location

天涯浪子 提交于 2019-12-14 04:21:36
问题 Problem: The user can choose how long and when start to track your locaton (Like today from 08:00 to 16:00). So during this interval my application will listen for the location every 5 minutes (this time can be changed, it's a user's preference). What I'm thinking: Making a service to be running and listenning for coming of the GPS or network locations during the time interval definned by the user. Problem: The service can be removed for running a long time? I need to registers listeners to

GPS reading cant be retrieved

*爱你&永不变心* 提交于 2019-12-13 08:37:15
问题 i want to use GPS in my App. but when i tried to retrieve GPS readings as shown belwo in the code, Android studio gave me the belwo mentioned error despit all the required permissions are added to manifest file code : LocationManager lm = (LocationManager) ctx.getSystemService(Context.LOCATION_SERVICE); LocationListener ll = new LocationListener() { @Override public void onLocationChanged(Location location) { Log.w(TAG, "onLocationChanged"); } @Override public void onStatusChanged(String

onLocationChanged just called once using network provider

被刻印的时光 ゝ 提交于 2019-12-13 07:31:48
问题 i have a problem using location listener and location manager. I'm using class that i found on the Internet public class MyLocationListener implements LocationListener { public void onLocationChanged(Location location) { home_text.setText("Location Change"); } public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } public void onProviderDisabled(String provider) { // TODO Auto-generated method stub } public void onProviderEnabled(String

Does LocationManager:NETWORK_PROVIDER work without GPS enabled?

a 夏天 提交于 2019-12-13 06:03:44
问题 I'm wondering why my app still finds location although the GPS is disabled. So I asked myselft why this is possible and I have too less knowledge about this. Maybe the NETWORK_PROVIDER needs no GPS? I promise, GPS is really disabled. Can anyone tell me how this is possible? I have this in my App: in oncreate(): locationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE); Method: public void getGpsLocation(){ locationManager.requestSingleUpdate(LocationManager.NETWORK

android LocationListener not stopping GPS use

笑着哭i 提交于 2019-12-13 02:54:34
问题 In my service , in some scenarios I can't stop the GPS from searching and draining the device battery. LocationListenerAgent.java @Override public void onCreate() { thisContext = this; // Register ourselves for location updates networkListener = new LocationListenerAgent(); gpsListener = new LocationListenerAgent(); lmgrNet = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE); lmgrGps = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE); gps_enabled = lmgrGps

how to run locationlistener in background

徘徊边缘 提交于 2019-12-13 00:34:40
问题 I would like to run a locationlistener on my app, that send after every 10m or every 5 seconds an new "Popup". Later I will send my data to the cloud. This is my GPSTracker class: import android.app.AlertDialog; import android.app.Service; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import