views:

239

answers:

2

Just started working with android and ran into a small problem. I am have a TabActivity that is loading 3 other Activity classes. This works great. I then have a button on the other Activity classes that I would like to launch a MapActivity. When I do that I keep getting a Force Close.

I googled but I cannot figure out if it is the manifest file or something else. The idea is the tabs are showing location information and you click a button to plot it on the map and get directions.

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

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

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

If I launch any other activity it works but not launching the mapactivity. If I take the mapactivity class and put it in a new project it works.

My manifest

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

<application android:icon="@drawable/icon"    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=".LocationChicago" 
              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> 

thougths?

A: 

I had the same problem, wanted to launch map activity from an other activity over onClick-event, the problem was: errors in the MapActivity

If you are using eclipse try to run "debug as" without setting any breakpoints

paul
+1  A: 
<action android:name="android.intent.action.MAIN" />

inside of the mapactivity's instance ACTIVITY field in the Manifest file does it.

So if you have a MapActivity named QMap, the following code in the Manifest actually works:

<activity android:name=".QMap"><action android:name="android.intent.action.MAIN" /></activity>

Hope it helped

Martin A