【发布时间】:2017-04-16 02:56:35
【问题描述】:
这是场景: 我的单个应用程序中有 2 个模块(在 Android Studio 中,文件 -> 新建 -> 新模块)。
- 模块 A
- 模块 B
模块 A(它不是库项目。 它的 gradle 以应用插件开头:'com.android.application')。
模块 B(也不是库模块)。
在模块 B 中,我需要调用一个属于模块 A 的 Activity(比如 MainActivity)。
模块 A 清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abc.emergencycontacts">
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_CONTACTS"></uses-permission>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true">
<activity android:name=".EmergencyContactsActivity" android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
模块 B 清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abc.secondaryactivity">
<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">
<activity android:name=".BaseAppActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
如何实现?
请注意,我不能在模块 B 中添加模块 A 的依赖项,因为模块 A 不是库模块。
等待您的宝贵回复。
【问题讨论】:
-
我不完全了解您的情况?您指的是两种不同的应用程序吗?
-
@MuratK。很抱歉让您感到困惑。我说的是同一个应用程序的 2 个不同模块。编辑了问题。
-
@MuratK。它没有。您建议的链接处理应用程序和模块之间的通信。我正在处理的是两个模块之间。不涉及应用模块。
-
这方面有什么更新吗?
标签: android android-studio android-intent android-activity module