Geolocation failed on Android webview and browser - android

I am facing a problem while working on Android Emulator. I am interested in setting the mock location through the LocationManager class and reading the geolocation in the Webview. I cannot read the location in the Webview where the location is read through the HTML5 geolocation API. I have tried on different versions of Android emulator (for API level 8, 12). I looked into previous questions at stackoverflow, but no luck. Let me know if I am missing anything.
I noticed the following issues in my implementation:
(In the logcat) WebChromeCliet was notified that the geolocation service failed to start.
I tried to set mock location through geo fix telnet command. I did not notice any corresponding information in the logcat messages.
Similar problem I noticed in the Android Browser. The browser also did not detect the location after geo fix command.
FYI, in my code,
1. The project settings include ACCESS_MOCK_LOCATION, ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION
The emulator has the settings for "mock locations" and "GPS support". I also enable
geolocation and gps provider.
I will appreciate any help or suggestions.

In order to use html5 geolocation you have to use uses-permission android.permission.ACCESS_FINE_LOCATION. The html5 geolocation does not work when just coarse location is requested.
Alternatively, it might or might be possible to use uses-feature android.hardware.location.gps for an optional use, even though I haven't managed to have the html5 geolocation working with uses-feature (is it a limitation of the Android SDK?).

Related

Mock location doesn't work in third-party app

Ok, so ive setup mock location in dev tools then set a fake location in special app, in gmaps it seems working, but in my courier app it just shows that location isn't enabled, however it is. I am just interested why it doesn't work as intended. Thank you.
Without faking it seems working fine.
And i dont have source code for this app, sure.

Unity Crashes Location.Service () In Android Device

I am using unity v5.5.3f1. And I am working on Unity Location.Service() to get user's GPS co-ordinates. I use the Code Snippet in the Unity Manual to use the GPS in unity. But when I run this code snippet in the Android Device, It crashes the Application. I referred and worked with some solution that are suggested in google, but didn't work. Even the Patches delivered by Unity Dev Team. So Can somebody help to solve this out, what my purpose is to use GPS and get the Location Co-ordinates.
References :
To use GPS :- unity location Service
To Patch : To use the Patch, but version error occurred, 5.5.3f1 is missing here
Note : using the Unity Version 5.5.3f1 on Windows 10 Platform, Testing on Android 4.1

alt beacon cordova not detecting beacons

I have a native Android SDK that uses the latest AltBeacon library.
I use my SDK within several Apps to detect beacons and perform business logic.
I now need to include my SDK within a Android Cordova app but it does not detect any beacons. (It does work within an iOS Cordova app). This is probably due to the Bluetooth management being controlled by Cordova and hence not allowing the Altbeacon lib to do it's thing.
Should the Altbeacon lib work within the Android Cordova environment and if so can someone point me in the right direction to get this to work.
I suspect the main issues are:
You need to set up the Android AppManifest.xml to enable Bluetooth LE permissions, and declare the scanning service. The native library AAR file gets this into your native app's manifest via manifest merging. You probably need to copy the entries manually from here.
On Android 5+ you need to request location permissions at runtime to scan for BLE beacons, otherwise you will get no results. I have not configured a Cordova app to request location permissions on Android, but you may get some hints from this answer.
If you do both these things and still have trouble, I would capture a LogCat excerpt and look for anything bluetooth related coming frin your app, and post the results in your question.

Google Play or HTML5 geolocation

I am currently an app which fetches user location at regular interval. I am using google play services api for that. It works fine. But sometimes it fails to get location even if it connects to playstore. I found none these issues with foursqaure app. I came to know that they are using HTML5 geolocation api from stackoverflow itself.
how foursquare determine a user location?
How can i implement this Geolocation api in my app?
What are the benefits and problems of using this api?
That's a very very broad question.
The easiest solution is implement what you need to be done in javascript, for example getting a position:
navigator.geolocation.getCurrentPosition(function(position) {
do_something(position.coords.latitude, position.coords.longitude);
});
Now, where to run this code, a straightforward solution is just running it inside a webview.
Other alternatives for running Javascript on android are V8 or Rhino.
I really can't help you any further, considering you never tell us what you want to do with the geolocation.

Simulate Mock Location on Android Device via DDMS

I have a GPS navigation application for Android 2.3.3 which I have been working on. I am currently trying to simulate locations via a GPX file through DDMS. While this works perfectly find on the android emulator, I am unable to get it working on an actual device.
I am able to see the device on the under the "Devices" tab, but I am unable to send any mock location data, or GPX data as the options are under "Emulation Control" tab are grayed out.
I have noticed that previous questions on StackOverflow mention that it is not possible, however the Google docs titled "Using DDMS" - http://developer.android.com/tools/debugging/ddms.html state the following (at the bottom of the page)
Setting the location of the phone
If your application depends on the location of the phone, you can have
DDMS send your device or AVD a mock location. This is useful if you
want to test different aspects of your application's location specific
features without physically moving. The following geolocation data
types are available to you:
I am just wondering how to send fake location data to a device via DDMS.
Thank you for your help in advance, and I really appreciate it.
Bilzac, your understanding is correct. Simply put, Android's documentation is misleading. Many developers have been confused by this. You cannot load a gpx file and send to device like you do on the emulator contrary to what the documentation suggests.
Possible if you activate mock locations on your device.
Than add ACCESS_MOCK_LOCATION permission to your manifest.
You can write now your own MockLocationManager which generates mocj locations.
Easiest way is to you use an app which generates mock lactions for you. GPS Route Simulator works quite fine. Possible to store kml files on the sdCard or defines own routes

Categories

Resources