<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Drew5.NET &#187; MapActivity</title>
	<atom:link href="http://drew5.net/tag/mapactivity/feed/" rel="self" type="application/rss+xml" />
	<link>http://drew5.net</link>
	<description>My 5 Cents</description>
	<lastBuildDate>Mon, 28 Nov 2011 20:14:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Android Activity Not Launching MapActivity</title>
		<link>http://drew5.net/2010/05/05/android-activity-not-launching-mapactivity/</link>
		<comments>http://drew5.net/2010/05/05/android-activity-not-launching-mapactivity/#comments</comments>
		<pubDate>Wed, 05 May 2010 15:01:50 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Google Maps API]]></category>
		<category><![CDATA[Help]]></category>
		<category><![CDATA[MapActivity]]></category>

		<guid isPermaLink="false">http://drew5.net/?p=286</guid>
		<description><![CDATA[I have decided to play around with Android and started out using the Google API for Maps.  My goal is to create an app that has a tab view that you can tab through some info and on the tabs there will be a button to launch the Google Map to show the location of [...]]]></description>
			<content:encoded><![CDATA[<p>I have decided to play around with Android and started out using the Google API for Maps.  My goal is to create an app that has a tab view that you can tab through some info and on the tabs there will be a button to launch the Google Map to show the location of the point of interest and show where you are and provide directions.  I have the tab view working great but when I try to fire off an event for the MapActivity that is where it fails.</p>
<p>If I create my own MapActivity project it works fine, but when I include the class in my tab project it fails.</p>
<p>Here is what I have:</p>
<pre class="brush:java">public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location_tab);
...
Button btnMap = (Button) findViewById(R.id.btnMapview);
btnMap.setOnClickListener(mMapListener);
...
}</pre>
<p>And my Listener</p>
<pre class="brush:java">private OnClickListener mMapListener = new OnClickListener() {
        public void onClick(View v) {
        	Intent mapIntent = new Intent(getApplicationContext(),LocationMap.class);
        	startActivity(mapIntent);
        }
 };</pre>
<p>And here is my Map Class:</p>
<pre class="brush:java">public class LocationMap extends MapActivity {

	MapView mapView;
    MapController mc;
    GeoPoint p;

	@Override
	protected boolean isRouteDisplayed() {
	    return false;
	}

    /** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mapView = (MapView) findViewById(R.id.myMapView);
        mapView.setBuiltInZoomControls(true);

        mc = mapView.getController();
        String coordinates[] = {"40.750386", "-73.976773"};
        double lat = Double.parseDouble(coordinates[0]);
        double lng = Double.parseDouble(coordinates[1]);

        p = new GeoPoint(
            (int) (lat * 1E6),
            (int) (lng * 1E6));

        mc.animateTo(p);
        mc.setZoom(17);
        mapView.invalidate();

	}
}</pre>
<p>I get a force close each time I click the button.  I have swapped out my LocationMap.class with a standard activity class and that works fine.  I have put my LocationMap class in it&#8217;s own project and that works fine as well, but together&#8230;no dice.</p>
<p>Any thoughts?  Here is my <a href="http://stackoverflow.com/questions/2776340/mapactivity-launching-from-onclicklistener" target="_blank">StackOverflow </a>post</p>
]]></content:encoded>
			<wfw:commentRss>http://drew5.net/2010/05/05/android-activity-not-launching-mapactivity/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

