android-location

Sending data from Android to a PHP server

北城余情 提交于 2019-12-22 10:37:21
问题 I am having an application in android and I want to send the latitude and longitude of the android mobile to the web PHP server through a url ( like=..mydata.php?lat=76867&long=87979 ). I am having the php code that saves the data in database if this url is hit. All I am not getting is that how to send the latitude and longitude through my android mobile phone to the PHP server. 回答1: Building upon @DarkXphenomenon answer, make sure you have the right permissions. // to retrieve location <uses

Caused by: java.lang.SecurityException: “gps” location provider requires ACCESS_FINE_LOCATION permission

我与影子孤独终老i 提交于 2019-12-22 06:37:22
问题 I already set permission. Why do I still get this error? Caused by: java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission. My manifest contents: <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> My Activity code:

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

末鹿安然 提交于 2019-12-22 05:43:26
问题 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

Need android activity to wait until GPS location obtained

喜欢而已 提交于 2019-12-22 05:35:15
问题 Sorry for my english. I'm trying to get a single location from GPS to put on global variables latitude, longitude. GPS turns on, but the activity goes on before data is retrieved from GPS. My needs in other words... method getCurrentLocation() must finish only if a location has been found and the longitude and latitude variables are filled, so I could use them in other method. I know... user has to wait... I will solve this forward showing something on screen. What should I do? Thank you I

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

喜你入骨 提交于 2019-12-21 23:52:21
问题 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

Is it possible to get a notification when any location provider is enabled/disabled and ascertain what action occurred?

喜夏-厌秋 提交于 2019-12-21 08:17:08
问题 I wish to receive a notification when the user enables or disables either Network or GPS locations, and importantly I wish to know which one they have changed and how. I have a broadcast receiver for the android.location.PROVIDERS_CHANGED broadcast intent and this is receiving the correct broadcast. I now need to try and determine which action has occurred i.e. enable or disable and which provider has been changed. I know that I could keep the state of each provider and then when I receive

getLastKnownLocation() always return the same location

泄露秘密 提交于 2019-12-21 04:20:16
问题 I'm tring to get the location from the gps/netwrok by best provider but always it's return the same location, also i can see that on google map there is a sign to my right location. please anyone can tell me what i'm doing wrong? My activity is: public class MainMenu2 extends Activity implements LocationListener, OnClickListener on my onCreate i have: if(isGooglePlay()){ setContentView(R.layout.menu_2); setUpMapIfNeeded(); } isGooglePlay method: private boolean isGooglePlay() { // looks if

Android getMaxAddressLineIndex returns 0 for line 1

别来无恙 提交于 2019-12-21 03:29:23
问题 For some reason the implementation of getMaxAddressLineIndex has recently changed. Now this method returns 0 for line 1. I have an existing code, which used to work: i<address.getMaxAddressLineIndex( ). However, it is broken somehow. I don't know if it is due to the new Google Api or something else. Can someone please confirm me here what is going on? 回答1: I had the same issue and this just a workaround. if (address.getMaxAddressLineIndex() > 0) { for (int i = 0; i < address

What is the difference between shouldShowRequestPermissionRationale and requestPermissions?

末鹿安然 提交于 2019-12-20 19:04:52
问题 I am building an app that requires user location. I am following the Android training documentation from here which says: shouldShowRequestPermissionRationale return the boolean indicating whether or not we should show UI with rationale for requesting a permission (dangerous permission, ACCESS_FINE_LOCATION) Now in this code (taken from the documentation itself) : if (ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { //

how to find the correct distance between two geopoints in map?

不问归期 提交于 2019-12-20 14:47:44
问题 I need to develop app where user has to locate his car that he has parked and show distance between him and car parked.I used GPS and location services. For distance i used haversine formula but the distance always shows 0 meters. I tried a lot searching for solution in google but dint get any correct solution. Can anyone give their suggestions? 回答1: Google Docs have two methods If you are getting lat/lon from GeoPoint then they are in microdegrees. You must multiply by 1e6. But i preferred