Resources‎ > ‎Tips and Tricks‎ > ‎Android‎ > ‎

Useful intents/actions that I've used

Favourite Intents

These are, or at least seem to be, the harder to find intents or the ones I use most commonly.  There are also published ones at http://developer.android.com/guide/appendix/g-app-intents.html

Google Navigation

 
Launch Google's Navigation By Location - Driving
     new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:ll=" + mLatitude + "," + mLongitude));
 
Launch Google's Navigation By Location - Walking
     new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:ll=" + mLatitude + "," + mLongitude + "&mode=w"));
 
Launch Google's Navigation By Address - Driving
     new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=an+address+city"));
 

Google Map with Pin

new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=51.123456,-114.123456 (" + pinName + ")");
 

Google/HTC Calendar

 
Launch Google's Calendar - non-standard
Intent calendarIntent = new Intent();
calendarIntent.setClassName("com.android.calendar", "com.android.calendar.AgendaActivity");
or 
Intent calendarIntent = new Intent();
calendarIntent.setClassName("com.google.android.calendar", "com.android.calendar.LaunchActivity");
 
Launch HTC's Calendar
Intent calendarIntent = new Intent(Intent.ACTION_MAIN);
calendarIntent.setComponent(new ComponentName("com.htc.calendar", "com.htc.calendar.MonthActivity"));
 
Use the package manager to determine which one is active on the device.
final PackageManager packageManager = getPackageManager();
List<ResolveInfo> list = packageManager.queryIntentActivities(calendarIntent, 0);
if ( list.isEmpty()) { ....

Comments