2015-01-02 2 views
1

나는 하위 메뉴를매니페스트에 인 텐트를 추가하는 방법은 무엇입니까?

Intent k = new Intent();// = new Intent(MainActivity.this,AddContact.class); 
      k.setAction("com.example.dbtest2.AddContact"); 
      k.addCategory("android.intent.category.DEFAULT"); 
      startActivity(k); 

를 사용하여 연락처에 대한 세부 사항을 추가하기 위해 다른 활동으로 이동 내 응용 프로그램이 의도를 가지고이 매니페스트입니다 :

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.dbtest2" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk 
     android:minSdkVersion="14" 
     android:targetSdkVersion="21" /> 

    <application 
     android:allowBackup="true" 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name=".MainActivity" 
      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=".AddContacts"> 
      <intent-filter > 
       <action android:name="com.example.dbtest2.k"/> 
       <category android:name="android.intent.category.DEFAULT"/> 
      </intent-filter> 

     </activity> 
    </application> 

</manifest> 

하지만 로그 캣은에 발견 어떤 활동을 말한다 핸들 의도! 활동이 매니페스트에 추가되었습니다. 어느 것이 .addContact .. 인 텐트와 활동을 매니페스트에 올바르게 추가 했습니까?

+0

'<활동 안드로이드 : ". AddContacts"이름 => '당신은 AddContact이 **이야 선언 **. AddContact가 아닙니다. –

+1

바로 그거야! 고맙다 형제 :) – Salah

답변

0

자신의 응용 프로그램에서만 Activity을 시작하는 경우 이렇게하지 않아야합니다. 당신은 매니페스트에서 intent-filter를 제거하고 단지 다음과 같이 명시 적으로 Intent 사용하여 Activity를 시작해야합니다

Intent k = new Intent(MainActivity.this, AddContacts.class); 
startActivity(k); 
관련 문제