我编写了两个不同的应用程序,我们将它们称为 AppA 和 AppB。我正在尝试使用意图从 AppB 启动 AppA 中的活动。我正试图以明确的意图来实现这一目标。
在 AppB 中,我创建如下意图:
ComponentName cn = new ComponentName("com.example.user.appa",
"appaActivity");
Intent infoIntent = new Intent();
infoIntent.setComponent(cn);
infoIntent.setAction("com.example.DO_SOMETHING");
infoIntent.putStringArrayListExtra("arrList", incInfo);
startActivity(infoIntent);
Run Code Online (Sandbox Code Playgroud)
在 AppA 的 AndroidManifest.xml 中,我包含了以下内容:
<activity
android:name=".appaActivity"
android:label="@string/title_activity">
<intent-filter>
<action android:name="com.example.DO_SOMETHING"/>
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
当我尝试运行 AppB(将 Intent 发送到 AppA)时,出现以下错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.user.appb/com.example.user.appb.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.user.appa/appaActivity}; have you declared this activity in your AndroidManifest.xml?
Run Code Online (Sandbox Code Playgroud)
因为我可以清楚地看到我已经在 AppA AndroidManifest.xml 中定义了 appaActivity,所以谁能告诉我我可能会忽略什么?