android-location

Wierd and very unexpected issue with location.getAccuracy()

倾然丶 夕夏残阳落幕 提交于 2019-12-02 06:56:57
Problem: I have tried using the new FusedLocationProviderClient and the deprecated FusedLocationApi to receive location updates on my app using a Sony Xperia Z2 and Huawei Honor 8 . Everything works fine initialy. However it seems that after x amount of location requests the accuracy number NEVER drops below 10.0 using location.getAccuracy(); // 10.0 What I have tried: Uninstalling and reinstalling the app does no difference. Restarting the phone, same result. Yes I have LocationRequest.PRIORITY_HIGH_ACCURACY ... no different result. What might have worked: Did a factory reset. Whooppaa

Android requestLocationUpdates with GPS null

梦想的初衷 提交于 2019-12-02 04:46:34
private void getLocation(){ locationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); List<String> providers = locationManager.getAllProviders(); for (String provider : providers) { Log.e("GPS_provider: ", provider); } Criteria criteria = new Criteria(); bestProvider = locationManager.getBestProvider(criteria, false); Log.e("Best_provider: ", bestProvider); locationListener = new LocationListener() { public void onLocationChanged(Location location) { // Called when a new location is found by the network location provider. Log.e("Loc_changed", ""+ location

Does the geocoder work on emulators

岁酱吖の 提交于 2019-12-01 20:45:00
I am using the geocoder and it worked just fine on my device but not working on emulators tried it on 2.2 and 4.2.2 didn't work; this is my code: Geocoder myLocation = new Geocoder(AzanTime.this, Locale.getDefault()); List<Address> myList=null; try { myList = myLocation.getFromLocation(latitude,longitude, 1); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Address address = (Address) myList.get(0); String addressStr = ""; if(address.getAddressLine(0)!=null){ addressStr += address.getAddressLine(0); } And the logcat: 01-11 09:31:07.573: E/AndroidRuntime(788):

SecurityException when calling getLastKnownLocation

自古美人都是妖i 提交于 2019-12-01 16:57:56
We've been getting reports of crashes on some devices when a user opens an Activity that calls the location manager's getLastKnownLocation method. We've requested all the required permissions in our application manifest: <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> Here is the stack trace: java.lang.RuntimeException: Unable to resume activity {com.projectname/com.projectname.ui.AtmFinderActivity}: java.lang.SecurityException: invalid package name: com.google.android.gms at android.app

Android runtime permissions on android versions below M?

早过忘川 提交于 2019-12-01 09:25:28
Recently my ola cabs application , after the latest update, asked for location permission at runtime. It did not open the location settings screen but just by clicking on yes, my location (GPS) of the device was turned on and the application proceeded without going to location settings or any settings screen. This feature was about to come in android M and is available on the MNC preview only, so I am guessing it cannot be used in devices at this point of time. So how is this application implementing this feature? It is using SettingsApi in the Play Services SDK 7.0+, to display the location

Get the currency symbol based on country

跟風遠走 提交于 2019-12-01 09:21:50
I have a TextView which display currencies. By default my textview's text is: $0.00 How can I make it so the $ changes based on user selection. I have the following code: Locale locale=new Locale("en", "US"); Currency currency=Currency.getInstance(locale); String symbol = currency.getSymbol(); Toast.makeText(getActivity(), symbol, Toast.LENGTH_SHORT).show(); Which shows $ but if I have the following: Locale locale=new Locale("en", "AU"); Currency currency=Currency.getInstance(locale); String symbol = currency.getSymbol(); Toast.makeText(getActivity(), symbol, Toast.LENGTH_SHORT).show(); it

Getting location offline

橙三吉。 提交于 2019-12-01 08:44:01
I want to get the value of Longitude and Latitude of my current locatoin when offline and save the current location to its database. Is it possible to get the longitude and latitude of the device when mobile data and wifi are off but the GPS is ON? Just use this code. Make sure the user hasn't selected wifi only or network only option in his location setings. it has to be high accuracy or GPS only. This piece of code will work. public class Location extends AppCompatActivity { LocationManager locationManager; Context mContext; @Override protected void onCreate(Bundle savedInstanceState) {

Android LocationClient.getLastLocation() returns old and inaccurate location with a new timestamp

*爱你&永不变心* 提交于 2019-12-01 07:33:45
I've been using the fused location provider since its release and I am pretty happy with it (way better than the old system). But I ran into a peculiar problem when using geofencing in combination with LocationClient.lastKnownLocation(). The setup is as follows: I drop several geofences around some home location (with increasing ranges). When I get the intent that a fence is crossed I retrieve the last known location from LocationClient and work with it. Apart from than I also registered for regular location updates with update mode PRIORITY_BALANCED_POWER_ACCURACY. Most of the times this

Get the currency symbol based on country

↘锁芯ラ 提交于 2019-12-01 07:09:11
问题 I have a TextView which display currencies. By default my textview's text is: $0.00 How can I make it so the $ changes based on user selection. I have the following code: Locale locale=new Locale("en", "US"); Currency currency=Currency.getInstance(locale); String symbol = currency.getSymbol(); Toast.makeText(getActivity(), symbol, Toast.LENGTH_SHORT).show(); Which shows $ but if I have the following: Locale locale=new Locale("en", "AU"); Currency currency=Currency.getInstance(locale); String

Android runtime permissions on android versions below M?

只谈情不闲聊 提交于 2019-12-01 06:57:21
问题 Recently my ola cabs application, after the latest update, asked for location permission at runtime. It did not open the location settings screen but just by clicking on yes, my location (GPS) of the device was turned on and the application proceeded without going to location settings or any settings screen. This feature was about to come in android M and is available on the MNC preview only, so I am guessing it cannot be used in devices at this point of time. So how is this application