无法在Android的库模块启动活动模块、Android

2023-09-12 05:00:05 作者:我们都没错 只是不适合§

要我的Andr​​oid应用程序的项目,我加入其中包含一个名为SampleDataMenuActivity活动的模块。没有什么特别的这一活动 - 这是用新建模块添加 - >Android的图书​​馆,在Android的演播室对话,包括由Android的Studio生成的Hello World的code

To my Android app project, I added a module which contains an activity named "SampleDataMenuActivity". There is nothing special to this activity - it's added using the "New Module" -> "Android Library" dialog in Android Studio and includes the "Hello World" code generated by Android Studio.

该应用的Andr​​oidManifest.xml中包括(从模块):

The AndroidManifest.xml of the app includes (from the module):

<activity
    android:name="com.sample.sampledata.SampleDataMenuActivity" >
    <intent-filter>
        <action android:name="android.intent.action.SampleDataMenuActivity" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>

在应用程序的build.gradle:

In the build.gradle of the app:

dependencies {
    (...)
    compile project(':sampledata')
}

在该项目的settings.gradle:

In the settings.gradle of the project:

include ':sampledata', ':app'

在我的应用程序的主要活动,我想用导航到活动的模块:

In the main activity of my app, I want to navigate to an activity in the module using:

startActivity(new Intent("com.sample.sampledata.SampleDataMenuActivity"));

该项目建立得很好,但是当我轻点按钮应该是我失败的模块中的活动,报告:

The project builds just fine, but when I tap the button that should take me to the activity in the module it fails, reporting:

android.content.ActivityNoFoundException: No Activity found to handle Intent ( act=com.sample.sampledata.SampleDataMenuActivity )

我错过了什么?

What did I miss?

推荐答案

我发现错了,也许我应该删除的问题。但因为它是upvoted,Somone的其他人可能有兴趣在这样的回答:

I found the mistake, and perhaps I should remove the question. But as it was upvoted, somone else might be interested in this answer:

该清单应州:

<activity
    android:name="com.sample.sampledata.SampleDataMenuActivity" >
    <intent-filter>
        <action android:name="com.sample.sampledata.SampleDataMenuActivity" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>