GPS App for Android
How to start a GPS with Android Intent
You are wondering about the simplest way to start a GPS? We will show you how easy it is with an Android Intent.
In this article we will show you the easiest way how to start a GPS with Android Intent. All you need to know is your destination!
What are Android Intents?
The Android operating system provides a simple on-board tool to allow apps to communicate with each other. Intents are a very simple way for one app to call another on the same device. Simply put, Intents are URLs that, similar to web pages, contain the recipient and a function to be performed by the recipient.
For example like this maptrip://navigate?latitude=50.738912&longitude=7.106772
How to start a GPS to a given location?
First, you need to specify who should receive this intent: In our case and if you have installed MapTrip you would specify “maptrip://”
Next you need to tell the GPS what to do “navigate” (meaning to start a guidance) and where to go to “?latitude=y&longitude=x”.
You will get the best and most robust performance if you use coordinates instead of addresses. Coordinates are unambiguous while addresses can be very tricky and there may be multiple similar street names in one city which can only be differentiated by there ZIP code. Therefore, use the coordinate if you can!
Intents have no back channel
An Android Intent only provides a uni-directional communication. You can tell an application what to do, but it can not respond. Therefore it cannot tell you, if anything has gone wrong.
Imagine you use an intent to start a GPS to a given address. If that address is not unique or if something was misspelled, you would be stuck.
Use MapTrip API for deeper integration
If you need that sort of workflow, you should be using a deeper integration like the MapTrip API. It provides a backchannel and thus more feedback.
MapTrip can do much more than just guide you to a destination. Therefore, the Intent interface also has numerous functions that go beyond a simple transfer of coordinates.
In the video we explain a demo application that we provide in our GitHub account. It allows developers to easily see the possibilities of the Intent interface of our navigation app.
If you need a deeper integration of navigation in your own app, you can use the MapTrip API. This creates a feedback channel from the navigation system into your own app, so that information such as the current calculated arrival time (ETA) can be retrieved.