2012-06-24 40 views
0

我有两个项目有类似的启动画面和菜单活动,但是包名称不同。当我运行我的最新项目时,它将从另一个项目中拉取其他菜单活动。这是我在命名一些东西时弄错了什么吗?我检查了我的清单,一切看起来都是正确的。任何人都有过这种情况? 清单:android项目在eclipse中互相拉动

<activity 
       android:name=".Splash" 
       android:label="@string/app_name" > 
       <intent-filter> 
        <action android:name="android.intent.action.MAIN" /> 

        <category android:name="android.intent.category.LAUNCHER" /> 
       </intent-filter> 
      </activity> 
      <activity 
       android:name=".Menu" 
       android:label="@string/app_name"> 
       <intent-filter> 
        <action android:name="android.intent.action.MENU" /> 
        <category android:name="android.intent.category.DEFAULT" /> 
       </intent-filter> 
      </activity> 

Activity: 

package com.****.tools; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 

public class Splash extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.splash); 
     Thread timer = new Thread(){ 
      public void run(){ 
       try{ 
        sleep(3000); 
       }catch (InterruptedException e){ 
        e.printStackTrace(); 
       }finally{ 
        Intent openMainMenu = new Intent("com.*****.MENU"); 
        startActivity(openMainMenu); 
       } 
      } 
     }; 
     timer.start(); 
    } 
} 


package com.****.tools 

import android.app.Activity; 
import android.os.Bundle; 

public class Menu extends Activity{ 
    @Override 
    public void onCreate(Bundle savedInstanceState){ 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.menu); 
    } 

} 
+0

请问您可以发布您的清单文件,或者至少是' ..'线?如果可能的话,你的“最新项目”活动课 – jmishra

+0

@ ladiesMan217我加了他们。 – Intelwalk

回答

1

您使用动作打开actitty但因此它从旧

Intent openMainMenu = new Intent("com.*****.MENU");//<--------- 
        startActivity(openMainMenu); 

做笔记在新的清单没有定义新的动作名称应该从旧的其他明智的将不同它将会有一个选择对话框,其中有两个活动。

 <activity 
      android:name=".Menu" 
      android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="com.*****.MENU_NEW" /> 
       <action android:name="android.intent.action.MENU" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 

    Intent openMainMenu = new Intent("com.*****.MENU_NEW");//<--------- 
        startActivity(openMainMenu); 
+1

我明白你的意思了!我不敢相信我搞砸了这个名字!谢谢! – Intelwalk