android-location

Why can't I get the location by the NETWORK_PROVIDER as follows?

限于喜欢 提交于 2019-12-05 07:48:05
问题 It is very simple. But I see nothing appears on the logcat. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map_selection); LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); // Define a listener that responds to location updates LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { // Called when a new

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: Get current location in China

孤街醉人 提交于 2019-12-04 21:06:06
I need to get current location in China but current location manager is not working in china.Its not showing latitude and longitude. Please tell me how can I get this? Many Thanks Fact 1: All Google services are blocked in China. Fact 2: Although it gives a feeling that AOSP is nothing to do with Google, it's really not. The truth is that once you used NETWORK_PROVIDER to get a location, a message was send to Google location server to check out the location, and returned the location back to you. For the reason every Chinese knows about, you can't access the server, that's why when you combine

Android get location from cell tower

[亡魂溺海] 提交于 2019-12-04 20:51:24
Hi I want to get location from cell tower(Sim card) without internet. I had used below mentioned code it's give me only last location when network available. my requirement is to get location without WiFi or internet. can it's possible? package com.example.gpscelltower; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Timer; import java.util.TimerTask; import android.app.Activity; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import

Location Manager remove updates permission

本小妞迷上赌 提交于 2019-12-04 20:31:57
问题 I am using android studio and compileSdkVersion is 23 in that i am using below code if(locationManager != null){ locationManager.removeUpdates(GPSListener.this); } to stop gps update where GPS Listener is a class which implements LocationListener. but in removeUpdates line i am getting below lint warning Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with checkPermission ) or handle a potential SecurityException I am not

Android - How to get ETA from Google Maps App Intent? (Or Waze?)

ⅰ亾dé卋堺 提交于 2019-12-04 20:00:24
I'm working on android app witch will navigate to a place and do some stuff based on the ETA. I don't want to deal with navigation at all and this is why i use an Intent to open Google Maps App. Is there any way i can run a service to get the ETA from Google Maps App? Can i do it with Waze or any other navigation app? If not, what do you think about running a service wich will get ETA from Google Maps API every few minutes? Thanks for you time. Yirmi. 来源: https://stackoverflow.com/questions/31322856/android-how-to-get-eta-from-google-maps-app-intent-or-waze

location.getSpeed() not coming for Marshmallow, using Fused Location API

回眸只為那壹抹淺笑 提交于 2019-12-04 19:16:47
I'm using Fused Location API in my app ( getLatitude() , getLongitude() , getSpeed() , getElevation() , and distanceTo() ). It was working fine until I updated my phone (Moto X2 2014) to Marshmallow. Now I don't receive speed in the location object in my app, rest methods are responding normally. However, if I run navigation on google maps in the background, I seem to receive speed inside my app as well. Also, my app seems to work without any issues on Nexus 5X (Marshmallow) and other below API 23 phones. What could be the problem? Has anyone faced something similar before? On devices running

Unable to start service - Requires ACCESS_MOCK_LOCATION secure setting

蓝咒 提交于 2019-12-04 17:47:54
问题 I got an exception java.lang.RuntimeException: Unable to start service ... java.lang.SecurityException: Requires ACCESS_MOCK_LOCATION secure setting However I have in Manifest file: <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> What can be wrong ? 回答1: The permission needs to be outside the <application> element. Also, you will need to enable Mock Locations from Settings -> Applications -> Development (Nexus S, may vary on other devices). Reference 来源: https:/

Getting the nearest street/road coordinates in android

一个人想着一个人 提交于 2019-12-04 14:12:23
In javascript, using Google maps api s we specify options such as google.maps.TravelMode.DRIVING . Do we have any equivalent for TravelMode in android? I couldn't see anything in android.location.LocationManager or android.location.Criteria I've thought of following options: Using some TravelMode alternative, get coordinates approximated to nearest street/road. Alternatively, ( Not preferred as it will be slow ) get the coordinates normally and then probably send it to some google api(This will be pretty slow as there are many points) and get the coordinates corrected to the nearest street

Android show progress dialog while waiting for location

China☆狼群 提交于 2019-12-04 07:29:27
I'm developing location based app using this example: http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/ But when I turn on phone, the location isn't available right on that moment. So I would like to show progress dialog while waiting for the location. Wanna do this in the background using AsyncTask. Can you give any ideas how and where to do that? There is no need of AsyncTask because Location service already running in different process, Just implement the LocationListener and register it on resume method, and in onCreateActivity check if location is null, the show