locationmanager

GPS coordinates (using location manager) get printed as null

心已入冬 提交于 2019-11-27 08:45:42
问题 OnCreateMethod, LocationManager manager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); LocationListener listener = new LocationListener() { @Override public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } @Override public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Override public void onProviderDisabled(String provider) { // TODO Auto-generated method stub } @Override public void

Asking for permissions while using LocationManager

不羁的心 提交于 2019-11-27 08:25:39
问题 I've just started with Android programming and so far, I've just messed a little bit around buttons, textviews and some activities, but I would like to begin with services and GPS locations. In order to practise a little bit, I'm building a simple app that just shows the coordinates of the user. I've created my own service class with some methods, but whenever I try to implement the following one, my app crashes: @TargetApi(23) public Location getLocation(){ try{ locationManager =

OnLocationChanged callback is never called

孤人 提交于 2019-11-27 06:57:04
I am trying to get the users current location using the LocationManager . I have done a lot of research and can't seem to find anyone with the same problem. The OnLocationChanged callback never seems to be called. Below is my various code and the logcat. protected LocationListener locationListener; protected LocationManager locationManager; protected Context context; My OnCreate() method @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.v(TAG, "IN ON CREATE"); this.context = getActivity(); registerLocationUpdates(); } My registerLocationUpdates

Get Latitude and Longitude without inserting Sim Card and Start/Stop Gps from Application

时光怂恿深爱的人放手 提交于 2019-11-27 03:42:34
问题 I am trying to fetch Gps latitude and longitude, but i am having a query that whenever i try to fetch Lat & Long without sim card, it is not providing any info where as soon i insert my sim card, it provides me all information in desired manner. LocationManager mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); LocationListener mlocListener = new MyLocationListener(); mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, mlocListener); you can see

setTestProviderLocation() does not trigger calling of onLocationChanged()

跟風遠走 提交于 2019-11-27 03:35:47
问题 I'm trying to get this bit of code to work: Testing GPS in Android The problem is, when I run the test, onLocationChanged() is never called: public class LocationTest0 extends AndroidTestCase implements LocationListener { private Location received = null; public void testExample() { LocationManager lm = (LocationManager)this.getContext().getSystemService(Context.LOCATION_SERVICE); String testProvider = "Test"; if (null == lm.getProvider(testProvider)){ lm.addTestProvider(testProvider, false,

onLocationChanged is not called automatically

泄露秘密 提交于 2019-11-27 03:23:10
问题 I have a problem with onLocationChanged event in Android. Here's the triggering: case R.id.start: { Points.add(overlay.getMyLocation()); // Points' type is ArrayList<GeoPoint> mgr.requestLocationUpdates(best, 0, 3, locationListener); } break; And here's the onLocationChanged method: public void onLocationChanged(Location location) { i++; Points.add(overlay.getMyLocation()); MapOverlay mapOverlay = new MapOverlay(Points.get(i-1), Points.get(i)); map.getOverlays().add(mapOverlay); //does the

NETWORK_PROVIDER not providing updated locations

扶醉桌前 提交于 2019-11-27 03:11:16
LocationManager locationManager = (LocationManager)getApp().getSystemService(Context.LOCATION_SERVICE); //getApp() returns my Application object locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER , 1, 1, this); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1, 1, this); That's the code I'm using to listen. With GPS enabled, everything works fine. However, if I disable GPS and rely on network location, it gives me stale results -- in this case, from two days ago. I cannot get it to update. Calling getLastKnownLocation returns the same stale results.

Android check permission for LocationManager

假如想象 提交于 2019-11-26 23:24:51
I'm trying to get the GPS coordinates to display when I click a button in my activity layout. The following is the method that gets called when I click the button: public void getLocation(View view) { TextView tv = (TextView) findViewById(R.id.gps_coord_view); LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE); Location loc = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); tv.setText("Latitude: " + loc.getLatitude() + "\nLongitude: " + loc.getLongitude()); } I'm getting an error that says Call requires permission which may be rejected by user. Code should

Call requires permissions that may be rejected by user

半腔热情 提交于 2019-11-26 22:46:01
问题 I am trying to make an application that sends location updates of a user after every five minutes. I suppose my code is working just fine but i get an error regarding the permissions that are being used by the application. I am pretty sure that i have added the permissions in the manifest file. Can someone tell me what's wrong? Here is my code. MainActivity.java LocationManager locationManager ; String provider; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

isProviderEnabled(LocationManager.NETWORK_PROVIDER) return false

若如初见. 提交于 2019-11-26 22:00:48
问题 I am using NETWORK_PROVIDER to get latitude and longitude of the place. I'v already check the setting in the "location & security" and enable "use wireless networks". But "isProviderEnabled(LocationManager.NETWORK_PROVIDER)" always return false . Can anyone help me? Thank you in advance! Here is my code : LocationManager locManager=(LocationManager) getSystemService(Context.LOCATION_SERVICE); boolean isEnableGPS=locManager.isProviderEnabled(LocationManager.GPS_PROVIDER); boolean isEnableNTW