开发者

MapActivity launching from OnClickListener

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:the开发者_如何学Pythonme="@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?


<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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜