2016-10-18 47 views
1

我正在構建我自己的android的科爾多瓦插件。但是,當我從cordova應用程序調用cordova插件中的活動實現時,似乎我的活動java文件未被我的cordova應用程序檢測到。活動java沒有找到

雖然logcat的規定,

android.content.ActivityNotFoundException:無法找到明確的活動類{my.app.path/my.plugin.path.SampleActivity};你有沒有在你的AndroidManifest.xml中聲明這個活動?

奇怪的是,我的插件的路徑連接到我的應用程序的路徑。我很確定我已經在我的cordova插件中的AndroidManifest.xml中聲明瞭我的活動。

片段(AndroidManifest.xml中)

<activity android:name="my.plugin.path.SampleActivity" 
     android:screenOrientation="portrait"> 
    <intent-filter> 
    <action android:name="android.intent.action.MAIN" /> 
     <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
</activity> 

片段文件(plugin.xml)

<config-file target="AndroidManifest.xml" parent="app/src/main/application"> 
    <activity android:name="my.plugin.path.SampleActivity" 
     android:screenOrientation="portrait" 
     android:configChanges="orientation"> 
    </activity> 
</config-file> 

片段(PluginInterface.java)

@Override 
public boolean execute(String action, CordovaArgs args, CallbackContext mCallbackContext) throws JSONException { 

    this.mCallbackContext = mCallbackContext; 

    Context context = cordova.getActivity().getApplicationContext(); 
    Intent intent = new Intent(context, SampleActivity.class); 

    return true; 
} 

感激,如果任何人都可以提供幫助。謝謝。

回答

0

問題已解決。問題在於plugin.xml。通過從

<config-file target="AndroidManifest.xml" parent="app/src/main/application"> 
    <activity android:name="my.plugin.path.SampleActivity" 
    android:screenOrientation="portrait" 
    android:configChanges="orientation"> 
    </activity> 
</config-file> 

更改爲

<config-file target="AndroidManifest.xml" parent="/manifest/application"> 
    <activity android:name="my.plugin.path.SampleActivity" 
    android:screenOrientation="portrait" 
    android:configChanges="orientation"> 
    </activity> 
</config-file> 

完全解決了這個問題。