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

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

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

Postby nuisanceValue » Mon Jul 12, 2010 3:49 pm

Hey,

does anyone know is it possible to send multiple locations to the maps application and label them.

I am writing a kind of contact list which includes co-ordinates and I would like to be able to display them all, but also have popups with the name of the person and the ability to access the navigation functionality of google maps.

And maybe ring them too.

Thanks.
nuisanceValue
Freshman
Freshman
 
Posts: 7
Joined: Thu Jun 24, 2010 12:40 am

Top

Re:

Postby tannerresearch » Tue Aug 03, 2010 10:36 am

rakeshsoni wrote: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 }


I had the same problem and found that maps simply don't work on the emulator. I got that error regardless of what I did while using the emulator, but works fine on a physical device
User avatar
tannerresearch
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Jan 07, 2009 6:43 pm

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

Postby Profete162 » Mon Nov 01, 2010 2:15 pm

I have 2 big issues with this

1) When Latitude is activated, Google Maps open and show my location instead of my POI location! I have to quit Google Maps and come back again to focus on my POI location.

2) There are no marker on my POI location! such a shame, if I move a little bit the Map, My POI is lost.

So my question are: do you have the same feeling than me with this intent? Is there some workaround to fix that? (maybe an other intent)?

Thank a lot for any help, I think I will have to create my own MapActivity and I think that's a waste of time for such a little feature.
Profete162
Experienced Developer
Experienced Developer
 
Posts: 67
Joined: Fri Nov 27, 2009 6:07 pm

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

Postby sumit_android » Mon Nov 01, 2010 2:38 pm

hi,
can you please provide me some lines of your code, to go through this issue.

Thanks.
sumit_android
Junior Developer
Junior Developer
 
Posts: 19
Joined: Fri Feb 19, 2010 6:59 am
Location: India

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

Postby Profete162 » Mon Nov 01, 2010 7:07 pm

Hi.
I think the prblem come from GMaps.

My code ( the same than first post)

Code: Select all
final Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:38.899533,-77.036476"));
        startActivity(myIntent);


This code launch Google Maps.
First Time I launch it, as Latitude is activated on my phone, GMaps zoom on me and not my POI.

I quit GMaps, click again on the button of my app and then GMaps open on my POI but does not display any marker on the map, so it's kind useless.


Thank a lot
Profete162
Experienced Developer
Experienced Developer
 
Posts: 67
Joined: Fri Nov 27, 2009 6:07 pm

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

Postby kieu.hua » Thu Dec 16, 2010 5:22 pm

To test out the code, I wrote a simple project with a button to fire a google map
with some location to run on the emulator. I got an error, ActivityNotFoundException.

The error in logcat is
andaroid.content.ActivityNotFoundException: No Activity found to
handle Intent {act=android.intent.action.VIEW dat=geo:0,0?q=02142 }

public class TestMap extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.main);

ImageButton mapbtn = (ImageButton) findViewById(R.id.mapbtn);
mapbtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {

Uri uri = Uri.parse("geo:38.899533,-77.036476");
Intent it = new Intent(android.content.Intent.ACTION_VIEW,uri);
startActivity(it);

}
});

}
}

<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".TestMap"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />

I think I am missing something. Please help!!!
kieu.hua
Freshman
Freshman
 
Posts: 3
Joined: Thu Dec 16, 2010 1:57 pm

Top

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

Postby tannerresearch » Thu Dec 16, 2010 5:24 pm

See my earlier post
User avatar
tannerresearch
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Jan 07, 2009 6:43 pm

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

Postby kieu.hua » Thu Dec 16, 2010 5:41 pm

Thank you for reply. Yes, i did read most of the earlier post, before I posted mine. I also tried to read the Intent spec and other, but I didn't see anything wrong with my program.
kieu.hua
Freshman
Freshman
 
Posts: 3
Joined: Thu Dec 16, 2010 1:57 pm

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

Postby kieu.hua » Thu Dec 16, 2010 5:58 pm

I got it working on my emulator. I need to include map lib in my emulator. I think your earlier post said it only works on the real device, but it work on my emulator with map lib.
kieu.hua
Freshman
Freshman
 
Posts: 3
Joined: Thu Dec 16, 2010 1:57 pm

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

Postby tannerresearch » Mon Dec 20, 2010 6:39 pm

Oh, cool :-) Good to know
User avatar
tannerresearch
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Jan 07, 2009 6:43 pm

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

Postby Ignant » Thu Jan 13, 2011 12:10 pm

Hi,
I tried this tutorial but I still get the "No Activity found to handle the intent" error.
I created a simple project like Kieu.hua, a button that launches the intent. I added the Maps.jar to the project and Internet permission.
Is there anything else that I need to add?
I do not have an actual phone to test this on.
So any help with get this working on the emulator is very much appreciated.
Thank you
Ignant
Junior Developer
Junior Developer
 
Posts: 11
Joined: Sat Aug 28, 2010 10:20 pm

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

Postby dconrad » Tue Mar 01, 2011 6:29 pm

I got Google maps to display a marker and I worked around the problem of maps not working on the emulator in the following way:

Code: Select all
private void launchMap(String lat, String lon, String name) {
    Uri uri = Uri.parse("geo:0,0?q=" +
            lat + "," + lon + " (" + name + ")");
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    try {
        startActivity(intent);
    } catch (ActivityNotFoundException e) {
        AlertDialog.Builder dialog = new AlertDialog.Builder(this);
        dialog.setTitle("Location");
        dialog.setMessage(lat + ", " + lon);
        dialog.setPositiveButton("OK", null);
        dialog.show();
    }
}


The geo: URI looks like geo:0,0?q=48.8735,2.295 (Paris) instead of geo:48.8735,2.295, and if an ActivityNotFoundException occurs because maps isn't installed on the device, it just pops up a dialog with the latitude and longitude instead of crashing with a force close.

I got all these ideas from posts and articles from others; I just put the pieces together.
dconrad
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Mar 01, 2011 5:58 pm

Re:

Postby Cumatru » Mon Mar 14, 2011 11:42 pm

rakeshsoni wrote: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 }



Same problem here.
Any advices ?
Cumatru
Junior Developer
Junior Developer
 
Posts: 11
Joined: Sat Mar 12, 2011 4:19 am

Top
Previous

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 11 guests