Hello

I have a TabActivity that loads in 3 activity classes.  In those
Activity classes I have a button and an OnClickListener that tries to
open a MapActivity class.  When I click the button I get a force close
and error.

Uncaught handler: thread main exiting due to uncaught exception
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.company.Name/com.company.Name.LocationMap}:
java.lang.NullPointerException

I have searched to find an example of an Activity class launching a
MapActivity class but cannot find one.  If I swap out my MapActivity
class with a Activity class it works.

Here is my Activity Class that has the listener.

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.location_tab);

        Button btnMap = (Button) findViewById(R.id.btnMapview);
        btnMap.setOnClickListener(mMapListener);

}

 private OnClickListener mMapListener = new OnClickListener() {
        public void onClick(View v) {
                Intent mapIntent = new
Intent(getApplicationContext(),LocationMap.class);
                startActivity(mapIntent);

        }
    };

Here is my MapActivity class

protected boolean isRouteDisplayed() {
            return false;
        }

        @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();

        }

And my Manifest

<uses-permission android:name="android.permission.INTERNET" />

    <application android:icon="@drawable/logo"  android:label="@string/
app_name">
        <activity android:name=".Splash"
                  android:label="@string/app_name"
                  android:theme="@android:style/Theme.NoTitleBar">
                         <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".Locations"
                  android:label="@string/app_name"
                  android:theme="@android:style/Theme.NoTitleBar"></
activity>

        <activity android:name=".LocationNewYork"
                  android:label="@string/app_name"
                  android:theme="@android:style/Theme.NoTitleBar">
                  </activity>


        <activity android:name=".LocationSeattle"
                  android:label="@string/app_name"
                  android:theme="@android:style/Theme.NoTitleBar"></
activity>

                <activity android:name=".LocationMap"
                  android:label="@string/app_name"
                  android:theme="@android:style/Theme.NoTitleBar">


                </activity>

        <uses-library android:name="com.google.android.maps"/>
    </application>

</manifest>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to