navigator.geolocation.getcurrentposition throws Timeout error - android

I'm developing a cordova application that find a particular retailer on the map near to the user's current GPS coordinates. I used the navigator.geolocation.getCurrentPosition to get the user's current position and use the Google Maps API v3 javascript to do a text search to find the retailer on the map.
I have the standard and recommended settings in both Android and iOS config files, it works find on iOS but not on Android. I exported the APK file and installed on Moto G, the application name is listed in Settings -> Location -> Current Location Requests but the browser still throws Timeout error.
Any ideas what could be wrong and why unable to detect the current position?
EDIT: To add more info, sometime the application opens up and stays blank without any timeout alerts.

You must add the geolocation plugin to your project using the following command. This sets the appropriate permissions in your platform config.xml file to allow the APK to speak with the OS:
cordova plugin add org.apache.cordova.geolocation
More: http://docs.phonegap.com/en/3.2.0/cordova_geolocation_geolocation.md.html

Related

Ionic - how to change permissions requestor name

I have an Angular Ionic app that uses geolocation / Google Maps. When it requests permissions for location, on web and Android it uses the url (so localhost:4200, for example) and on iOS it just reads as "://".
Where do I configure the requestor name for permissions? I want it to read
"App Name" Would Like To Use Your Current Location
So for clarity: I don't want the url on Android/Web, and I don't want the blank string on iOS. I want it to read as the app name.
Let me know if you need more details.

Simple app to show map doesn't work android

I am doing online coursera class on android, and there is a simple application that is supposed to take a string for a location and show a map of where it is. I imported the maplocation project in android studio from this site https://github.com/aporter/coursera-android/tree/master/Examples/MapLocation, ran on the emulator, entered the address provided in the video and clicked "Show map" but there is nothing.
Screenshot:
In the error log it says:
06-30 18:14:55.317 2151-2151/course.examples.maplocation
E/MapLocation: android.content.ActivityNotFoundException: No Activity
found to handle Intent { act=android.intent.action.VIEW
dat=geo:0,0?q=washington+dc }
How do I resolve this? Why isn't an activity being started?
Since you are using an emulator, I have a suspicion that your emulator does not have an app installed that can view the coordinates. Try running the app on actual device instead. The emulator usually does not have Google Play Services installed and thus you probably don't have the Google Maps app installed on the emulator either. i.e. There is no app on the emulator that can open that location data.

Open here map url from mobile

I'm developing hybrid application and want to access to HERE map url from any device (android / ios / windows phone / web)
I tried to follow this answer : Create URL to here.com
But It's not working in all cases.
In my case, i tried this url : https://www.here.com/directions/drive/start:48.85,2.35/end:52.51,13.38
Android without Here map app installed : open m.here.com -> ok
Android with Here map installed : open m.here.com but do not find app installed -> failed
iOS without Here map app installed : open m.here.com -> ok
iOS with Here map app installed : open m.here.com and ask if we want to use app installed, but if i click yes, app say me 'cannot find itinerary' -> failed
Windows Phone 10 without Here map app installed : ask me to install Here map app, if i say yes, redirect to store with no result (failed), if i say no, error page -> failed
Windows Phone 10 with Here map app installed : open app but say me 'cannot find itinerary' -> failed
Web : ok
I have more errors than success cases, so i can't use this kind of url.
Is there a different kind of URL that I can use to open m.here.com if there is no installed application, and launch application if it is installed?
(or open m.here.com in all cases at least)
The deeplinking developer guide has been recently made public, you could use that.
https://github.com/heremaps/map-linkbuilder-app
http://heremaps.github.io/map-linkbuilder-app/
So, try creating share urls
(You'll get something like this: https://share.here.com/r/52.51607,13.37699,Berlin%2C%20Germany/51.05364,13.74082,Dresden%2C%20Saxony%2C%20Germany?m=d&t=normal)

404 Error when running TicTacToe sample (Android) against sample Google App Engine project (Java)

I set up the Android App and Google App Engine backend as seen in these two projects:
Android Connected App Engine Project
Java App Engine Backend Project
When I click a TicTacToe-field button, which triggers a request I get an 404 error: "Not found"
04-09 23:11:51.115: W/TicTacToe(26247): GetComputerMoveTask: 404 Not Found
04-09 23:11:51.115: W/TicTacToe(26247): Not Found
That is exactly the what https://myappname.appspot.com/_ah/api/ in the browser shows "Not Found".
Here is what I did:
Created an api project on App Engine Console
There created an Android Client Id with com.google.devrel.samples.ttt as package an my debug keys SHA1-fingerprint
There created a Web Client ID
Integrated the Android Project in eclipse. Updated DEFAULT_ROOT_URL in Tictactoe.java to "https://myappname.appspot.com/_ah/api/"
There updated the value of AUDIENCE in ClientCredentials.java by replacing the string "your_web_client_id" with the generated web-client-id from step 3
Integrated the Java backend project in eclipse.There updated the value of application in appengine-web.xml to myappname
Updated the values in /spi/Ids.java to reflect the web-client-id and android-client-id from step 2 and 3
Updated the value of google.devrel.samples.ttt.CLIENT_ID in war/js/render with web-client-id
Deployed the backend to google. Worked great - it opend the https://myappname.appspot.com/ page showing the correct page after deploying (servlet)
Deployed the android app and tried to make a move in TicTacToe. The app crashes.
I think its very suspicious my DEFAULT_ROOT_URL is set to "https://myappname.appspot.com/_ah/api/" in my Android app whereas this pages show just "Not found" in the browser.
Whats going wrong here?
Thanks in advance
Try to test your API at https://your_app_id.appspot.com/_ah/api/tictactoe/v1/ and see if that doesn't do what you want.
Research from this link:https://github.com/GoogleCloudPlatform/appengine-endpoints-tictactoe-android/blob/master/app/src/main/java/com/google/api/services/tictactoe/Tictactoe.java
Lines 60-74
https://github.com/GoogleCloudPlatform/appengine-endpoints-tictactoe-java/blob/master/src/com/google/devrel/samples/ttt/spi/BoardV1.java
Lines 29-31
I suspect you have the API URL wrong, and diving in the code its apparent that the above URL is correct.
No idea where are you getting the instructions for step 4 (in your list), but looking at Setup Instructions in the for the Android project, step 2, what you should do is:
Update the value of DEFAULT_ROOT_URL in src/com/appspot/api/services/tictactoe/Tictactoe.java to point to the location where you are hosting a Tic Tac Toe backend (based off of the Java backend example).
And the location in your case is crearly "https://myappname.appspot.com/".

Xamarin Forms Labs Geolocation sample

I downloaded the source for Xamarin Forms Labs, and was trying to run the geolocator sample for the android project. When you click the Get Position button, the location message returned is "Cancelled". I tried making a new xamarin forms project in VS by following these steps: file > new project > Xamarin PCL. When I install xamarin forms labs in that project and use it, I get the same message. I can, however, get the Windows Phone example to work. I'm not sure if maybe the Android emulator that installs with Xamarin can even connect to the network on my machine or not. That would explain why it cant get the location
(This is a little late, but just submitting in case anyone finds this via a search)
Double check your platform permissions.
For Android:
You must request the following permissions within your Android Project
ACCESS_COARSE_LOCATION
ACCESS_FINE_LOCATION
For iOS:
In iOS 8 you now have to call either RequestWhenInUseAuthorization or RequestAlwaysAuthorization on the location manager.
Additionally you need to add either the concisely named NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription to your Info.plist.
For Windows Phone:
You must set the ID_CAP_LOCATION permission.
Xamarin Forms
If you are developing a Xamarin Forms app, you could try using the Geolocator (Xamarin.Plugin) sample, just remember to add your permissions :)
Sample:
var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 50;
var position = await locator.GetPositionAsync (timeout: 10000);
Console.WriteLine ("Position Status: {0}", position.Timestamp);
Console.WriteLine ("Position Latitude: {0}", position.Latitude);
Console.WriteLine ("Position Longitude: {0}", position.Longitude);

Categories

Resources