[TinyTut] - Starting the Maps-Activity with an Intent

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

[TinyTut] - Starting the Maps-Activity with an Intent

Postby plusminus » Mon Nov 19, 2007 11:42 pm

[TinyTut] - Starting the Maps-Activity with an Intent


What you learn: You will learn how easy it is, to start the Maps-Activity with a passeg "geo"-URI in just two lines(or one if you want to :wink: ).

Difficulty: 0 of 5 :roll:

Description
The following Code sends an Intent to the OS, which will start the registered Map-Activity with the passed "geo"-URI.
In this case it is the White-House.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. try {
  2.         final Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:38.899533,-77.036476"));
  3.         startActivity(myIntent);
  4. } catch (URISyntaxException e) { }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Last edited by plusminus on Mon Sep 29, 2008 3:57 am, edited 2 times in total.
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby tagazok » Mon Nov 19, 2007 11:53 pm

wow, every day, android seems easier than the day before.
L'idiot ne savait pas que cela était impossible...
...alors il l'a fait.
tagazok
Junior Developer
Junior Developer
 
Posts: 12
Joined: Sun Nov 18, 2007 4:39 pm
Location: Nice / Paris

Route

Postby AndroidBorkCreature » Mon Feb 18, 2008 3:08 pm

Hello all,
is it possible to modify the intent and to add another location in order to view a route?


Best Regards,
Paul
AndroidBorkCreature
Freshman
Freshman
 
Posts: 5
Joined: Tue Feb 05, 2008 1:56 pm

Re: Route

Postby patrox » Sat Sep 06, 2008 5:01 pm

AndroidBorkCreature wrote:Hello all,
is it possible to modify the intent and to add another location in order to view a route?


Best Regards,
Paul


any news on that?? what parameters can we pass to the standar map activity?

also, is there a way to get a location from the mapview back to our application?
patrox
Freshman
Freshman
 
Posts: 8
Joined: Wed Apr 02, 2008 8:21 pm

Postby Artur79 » Sun Sep 28, 2008 1:51 pm

I had some errors in Eclipse with this code, but works after those small fixes:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW,
  3.  
  4.                                 Uri.parse("geo:38.899533,-77.036476"));
  5.  
  6.                 startActivity(myIntent);
  7.  
  8.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
Artur79
Developer
Developer
 
Posts: 26
Joined: Fri Sep 26, 2008 12:53 pm

Postby plusminus » Mon Sep 29, 2008 3:56 am

Hello Artur,

thanks for sharing. (replaced old stuff)
Best Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby Artur79 » Mon Sep 29, 2008 2:08 pm

just started to learn Android so I am going throught all novice tutorials, so expect more fixes like this :)
You may delete my posts if you applied a fixes to tutorial code.
Artur79
Developer
Developer
 
Posts: 26
Joined: Fri Sep 26, 2008 12:53 pm

Postby plusminus » Mon Sep 29, 2008 4:14 pm

Artur79 wrote:just started to learn Android so I am going throught all novice tutorials, so expect more fixes like this :)
You may delete my posts if you applied a fixes to tutorial code.


That would be great :!:
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Location

Postby NevinM » Tue Oct 14, 2008 12:39 am

How can you code this to open with current GPS location or pass no geo URI, so that Maps opens to the last location in maps?
NevinM
Developer
Developer
 
Posts: 36
Joined: Wed Oct 01, 2008 4:24 am
Location: Lethbridge, Canada

...or not?

Postby gustavo » Mon Nov 17, 2008 2:31 pm

tagazok wrote:wow, every day, android seems easier than the day before.


Yea, but now, dealing with maps seems harder each day...
gustavo
Junior Developer
Junior Developer
 
Posts: 12
Joined: Sun Mar 02, 2008 2:55 pm

Postby Audiofreq » Mon Feb 23, 2009 1:55 am

Hi,

If you are viewing a contact with an address clicking on the address opens the map application with the address written in a bubble.
If there is a potential number of possible addresses to display the option is given to the user.

How can i implement this intent?

I looked at the LogCat and when this activity is started the output is:

Starting activity: Intent { action=android.intent.action.VIEW data=content://contacts/people/24/contact_methods/1 comp={com.google.android.apps.maps/com.google.android.maps.MapsActivity} }


EDIT: Oops i figured it out.

For anyone interested the possible formats are:

geo:latitude,longitude
geo:latitude,longitude?z=zoom
geo:0,0?q=my+street+address
geo:0,0?q=business+near+city
Audiofreq
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Feb 23, 2009 1:50 am

Re: Route

Postby zoniq » Mon Nov 23, 2009 1:41 pm

patrox wrote:
AndroidBorkCreature wrote:Hello all,
is it possible to modify the intent and to add another location in order to view a route?


Best Regards,
Paul


any news on that?? what parameters can we pass to the standar map activity?

also, is there a way to get a location from the mapview back to our application?


I'm interested in that as well. Any news?
zoniq
Junior Developer
Junior Developer
 
Posts: 21
Joined: Mon Sep 28, 2009 12:33 pm

Calling Android Maps with URI

Postby ggerz » Fri Mar 26, 2010 12:02 pm

Hi there,

Calling google apps with an URI:

http://developer.android.com/guide/appe ... tents.html

(extracted from previous link) for geo we have
Google Maps geo:latitude,longitude
geo:latitude,longitude?z=zoom
geo:0,0?q=my+street+address
geo:0,0?q=business+near+city
VIEW Opens the Maps application to the given location or query. The Geo URI scheme (not fully supported) is currently under development.
The z field specifies the zoom level. A zoom level of 1 shows the whole Earth, centered at the given lat,lng. A zoom level of 2 shows a quarter of the Earth, and so on. The highest zoom level is 23. A larger zoom level will be clamped to 23.

If you want to experiment, more information here
http://geouri.org/2009/04/02/android-im ... ification/
ggerz
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Mar 26, 2010 12:30 am

Postby rakeshsoni » Wed Apr 28, 2010 3:04 pm

I am getting following exception when trying to run above code...... please help

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=geo:38.899533,-77.036476 }
rakeshsoni
Freshman
Freshman
 
Posts: 2
Joined: Sat Feb 13, 2010 3:49 pm

Re: [TinyTut] - Starting the Maps-Activity with an Intent

Postby sumit_android » Mon Jul 12, 2010 9:41 am

Hi,
please anyone give me the code to modify the intent in order to draw a route in between two different location on MAP.
sumit_android
Junior Developer
Junior Developer
 
Posts: 19
Joined: Fri Feb 19, 2010 6:59 am
Location: India

Top
Next

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests