2010-12-02 8 views
1

TicTacToeサンプルアプリケーションの後にコードをモデル化したので、私のアプリケーションは基本的に共通アクティビティを開始するシェルを持つアプリケーションです。共有ライブラリ(properties-> IsALibrary)としてフラグが立てられた独立したEclipseプロジェクトにあります。呼び出し側のアクティビティのプロパティにライブラリを追加しました。次のように私は共有ライブラリのコードを呼び出す:次のように呼び出し元の活動のためのライブラリアクティビティのmanifest.xmlに.Preferenceアクティビティを指定する方法

private void startGame() 
    { 
Intent i = new Intent(this, calendar.class); 
startActivityForResult(i, START_APPLICATION); 
    } 

私AndroidManifestは次のとおりです。次のように

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.calendar" android:screenOrientation="portrait" 
android:versionCode="1" android:versionName="1.0"> 
<application android:label="@string/app_name" 
    android:debuggable="true" android:icon="@drawable/icon"> 

    <activity android:name=".MainActivity" 
    android:screenOrientation="portrait" android:label="@string/app_name" 
    android:configChanges="keyboardHidden|orientation"> 
    <intent-filter> 
    <action android:name="android.intent.action.MAIN" /> 
    <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
    </activity> 

     <!-- This is defined in CalendarLib. Right now we need to manually copy 
      it here. Eventually it should get merged automatically. --> 
     <activity 
      android:name="com.library.calendar" > 
     </activity> 

<!-- <activity android:name=".Preferences" android:label="@string/prefTitle"--> 
<!-- android:screenOrientation="nosensor">--> 
<!-- <intent-filer>--> 
<!-- <action android:name="com.calendar.library.Preferences" />--> 
<!-- <catagory android:name="android.intent.catagory.PREFERENCE" />--> 
<!-- </intent-filer>--> 
<!-- </activity>--> 

</application> 

<uses-sdk android:minSdkVersion="4" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 


<supports-screens android:anyDensity="false" 
    android:resizeable="true" android:largeScreens="true" 
    android:normalScreens="true" android:smallScreens="false" /> 

</manifest> 

AndroidManifestは、共有ライブラリのためには、次のとおりです。

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.calendar.library" android:versionCode="1" 
android:versionName="1.0"> 
<application android:icon="@drawable/icon" android:label="@string/app_name"> 
    <!-- The activity tag here is currently not used. The main project must 
    currently redefine the activities to be used from the libraries. However 
    later the tools will pick up the activities from here and merge them automatically, 
    so it's best to define your activities here like for any regular Android 
    project. --> 
    <activity android:name="calendar" /> 

     <activity android:name=".Preferences" android:label="@string/prefTitle" 
      android:screenOrientation="nosensor"> 
      <intent-filer> 
       <action android:name=".Preferences" /> 
       <catagory android:name="android.intent.catagory.PREFERENCE" /> 
      </intent-filer> 
     </activity> 

</application> 
<uses-sdk android:minSdkVersion="4" /> 

</manifest> 

私は、共有ライブラリコードのActivityクラスで自分のメニューを定義し、次のように呼び出す:

case MENU_SETTINGS: 
    Intent intent = new Intent().setClass(this, Preferences.class); 
    this.startActivityForResult(intent, 0); 
    return true; 

設定をクリックすると、Instrumentation.javaのメソッドexecStartActivity()でSTART_INTENT_NOT_RESOLVEDが返されます。 execStartActivityは私が

mPackage="com.barrett.calendar" 
mClass="com.ifundraizer.calendar.library.Preferences" 

と他のすべてが驚くことではない、nullであることを確認を開始しようとしている意図を見てみます。

、私の質問は:

好みの活動の定義は、呼び出し元の活動のマニフェストにまたは共有ライブラリのマニフェストに属していますし、クラスの定義はXMLでどのようなものになるはずですか?

お時間をいただきありがとうございます。私は明らかに希望していますが、これは非常に混乱しています。

答えて

0

読むには、慎重にあなたの共有ライブラリマニフェストのコメント:

<!-- The activity tag here is currently not used. The main project TicTacToeMain 
     must currently redefine the activities to be used from the libraries. 
     However later the tools will pick up the activities from here and merge them 
     automatically, so it's best to define your activities here like for any 
     regular Android project. 
    --> 

は基本的にあなたがそれらの活動を使用するアプリケーションにあなた共有ライブラリマニフェストからのすべての活動をコピーする必要があります。私はあなたが実際にこの部分をコピーし、それをコメントアウトていることがわかり

<activity android:name=".Preferences" android:label="@string/prefTitle" 
     android:screenOrientation="nosensor"> 
     <intent-filer> 
      <action android:name=".Preferences" /> 
      <category android:name="android.intent.category.PREFERENCE" /> 
     </intent-filer> 
</activity> 

:基本的に、あなたのアプリケーションのAndroidManifest.xmlにこれを追加します。だからコメントを外してください。

+0

ありがとうございます、私にとってはうまくいきましたが、その解決法の変種でした。私は完全修飾アクティビティ(前方参照のXML equiv)とコードのコメントを解除する必要がありました。 – user330844

+0

または 'project.properties'の' manifestmerger.enabled = true'を使用してください – ChristopheCVB

+0

@ChristopheCVB、はい、今私たちはマニフェスト合併機能を使用できます。 – inazaruk

関連する問題