Table of contents:

Intents

An Intent provides a facility for performing late runtime binding between the code in different applications on Android platform. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed.

Supported intents

Intent category

Intent category gives additional information about the action to execute. For example, CATEGORY_LAUNCHER means it should appear in the Launcher as a top-level application, while CATEGORY_ALTERNATIVE means it should be included in a list of alternative actions the user can perform on a piece of data.

How to open Navigator Intent from another application

Geo intent

To open Navigator using geo intent use following method

public void openGeoIntent(String address, float lat, float lon, boolean navigate)
{
  String ext = navigate ? "&navigate=yes" : "";
  Uri uri = Uri.parse("geo:" + Float.toString(lat) + "," + Float.toString(lon) + "?q=" + Uri.encode(address) + ext);
  Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri);
  startActivity(intent);
}

Navigator geo intent can be opened using by one of variant below

HTTP intent maps.google.com

To open Navigator using HTTP intent using the host maps.google.com use following method

public void openHttpIntent(String address, float lat, float lon, boolean navigate)
{
  String ext = navigate ? "&navigate=yes" : "";
  String host = "http://maps.google.com/maps?f=d&daddr=";
  Uri uri = Uri.parse(host + Uri.encode(address) + "@" + Float.toString(lat) + "," + Float.toString(lon) + ext);
  Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri);
  startActivity(intent);
}

Navigator http intent can be opened using by one of variant below

HTTPS intent maps.google.com

To open Navigator using HTTPS intent using the host maps.google.com use following method

public void openHttpsIntent(String address, float lat, float lon, boolean navigate)
{
  String ext = navigate ? "&navigate=yes" : "";
  String host = "https://maps.google.com/maps?f=d&daddr=";
  Uri uri = Uri.parse(host + Uri.encode(address) + "@" + Float.toString(lat) + "," + Float.toString(lon) + ext);
  Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri);
  startActivity(intent);
}

This intent has same usage as HTTP intent.

Navigator/Intents (last edited 2015-02-25 09:18:20 by lubos)