I am implementing an APP with Xamarin.
In my APP I have set access fine location permission.
And in runtime I have allow the permission.
But sometimes, the APP still can't get the GPS location infomation.
(This happens in a low possiblity)
But once connect the phone to a network(router).
The GPS works again.
What would be the reason?
Here is code I use
var locator = CrossGeolocator.Current;
var position = await locator.GetPositionAsync(TimeSpan.FromMilliseconds(5000));
Related
I am using the location service (GoogleApiClient) in my application and I have to check the received location is mock or not. I am using the location.isFromMockProvider() for checking, and it was working fine for higher version of devices with all fake gps applications.
Here I am adding the scenarios that will fail.
Take Samsung S7 (I got from S7) or any other high end device.
Install "Fake GPS Go" application and set a fake location
Check the received location (location.isFromMockProvider() returns false)
Thanks in advance.
I have LeEco2. I am working on an app and I see something strange.
In my App permissions in Location, I see that location has been disabled for app but in Location->Location Access, it shows Allowed
In App Management, I see Permissions has no access to location
Location->Location Access in the settings is to enable the GPS and the Permissions in your app settings is Permission for your app to use the Location Service.
You can have the following.
You can request for Location Permission and It can be given while the GPS is still turned off.
LOCATION SERVICE could be on and your app could have got the permission but then user can go back and turn off either of them.
I suggest you always check if GPS is ON before triggering location permission and before using it as well.
I am developing both and iOS and Android version that requires GPS using Xamarin.
On iOS it's working fine, however now developing the Android version I have some issues with the GPS. It does not fetch the GPS but times out. However, on a emulator (using Genymotion) it fetches a coordinate right away. Note that I am using the Xamarin.Mobile (latest plugin 0.7.5).
private async Task<HelpPosition> CreateGeolocator ()
{
int accuracy = SettingsManager.Instance.GetSettings ().Accuracy;
Geolocator locator = new Geolocator (this) { DesiredAccuracy = accuracy * 10 };
Position p = await locator.GetPositionAsync (timeout: 10000);
return new HelpPosition{ Latitude = p.Latitude, Longitude = p.Longitude };
}
This always code times out after 10s. I have set the ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions.
The issue seems only to occur when indoors. However Google Maps is perfectly fine getting my exact position. And I have checked all settings in Location Services (Use wireless networks and Use GPS satelites). The device is a Samsung Note 2.
Never got Xamarin.Mobile working to satisfaction on Android indoors so I tested the only other option in Component Store avaliable: Geolocator. Works like a charm!
https://components.xamarin.com/view/GeolocatorPlugin
Edit It works better, but even with this plugin I get reports that the location received is off. The search for a better solution continues...
I am building a location aware app for Android using sencha 2.3.1 + phonegap 3.3.0, and use geolocation to show a list of destinations ordered by proximity to the user location.
Everything works fine if the setting for network-based location is on. But if I turn it off and leave gps only based location then it never gets detected.
The code is very basic, I tried both the sencha path:
Ext.device.Geolocation.watchPosition({
frequency: 10000,
callback: function(position) {
AppHelper.setCurrentLocation(position);//yeah!!
},
failure: function() {
AppHelper.setLocationModeOff();//oouch!
}
});
and the phonegap path:
var success = function(position) {
AppHelper.setCurrentLocation(position);
};
var fail = function() {
AppHelper.setLocationModeOff();
};
navigator.geolocation.watchPosition(success, fail,{ timeout: 30000 });
Result is the same, I tried waiting for a couple minutes for the geolock to happen but no sign of location service.
The phonegap location plugin is installed, the permissions are correct, and everything works if network location is enabled.
I am testing on a Sony Tablet S.
I am aware of this bug:
How to get user position by GPS in Sencha
But I checked the code and its is definetely fixed in sencha 2.3.1
I wil try on other devices but I was wondering if anybody experienced the same.
TIA.
EDIT:
I made an experiment using standard html5 code on my android device using systems default browser (webkit based).
I would access my settings page and change settings at each run.
Accessing http://html5demos.com/geo I get the following:
I started the device with network geolocation on and gps based location off:
I get a message that asks if I want to share my location I say yes, only this time everything works fine.
Turn off network based geolocation, gps still off:
Location detection fails. (as expected)
Turn on GPS, leave network geolocation off:
Geolocation fails silently, I don't get a request to use my location and subsequent activation of GPS based gelocation.
So my conclusion is: this is similar to what I noticed in phonegap. If network based geolocation is on everything works as expected. But if I have no network connection and gps is on that is pretty useless in my html5 app.
At least this is what happens on my device (sony tablet)
From my understanding of HTML5 geolocation API, that is expected behaviour, you just can't control if under the hood it is using gps or network location.
What's probably happening is that watchPosition(), when it is called, tries first a raw, quick positioning using network, then goes with the gps positioning to give you a better result (assuming you called it with the enableHighAccuracy parameter).
If you are disabling network positioning it probably gets stuck at the first point: as stated in cordova/phonegap's docs the permission to access coarse location is a requirement for geolocation to work.
(in app/AndroidManifest.xml)
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
I am guessing that revoking access to coarse location from the device settings somehow "overrides" the user permission given when installing the app.
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 receiving locations without actually initiating a location fix. This provider can be used to passively receive location updates when other applications or services request them without actually requesting the locations yourself. This provider will return locations generated by other providers.
So no, it's not likely to do you any good if there are no other location providers available.