[英]startActivityForResult: No Activity found to handle Intent
我有兩個項目: ProjectA和ProjectB 。 我現在嘗試使用以下代碼從ProjectA內的ProjectB打開活動B_Activity :
Intent intent = new Intent("com.orr.con.projectb");
startActivityForResult(intent, 0);
但出現以下錯誤:
android.content.ActivityNotFoundException: No Activity found to handle Intent
A_Activity的清單:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.or.test">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".A_Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
B_Activity的清單:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.orr.con.projectb">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".B_Activity" android:label="@string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
首先,我在設備上安裝ProjectB ,然后在ProjectA上安裝。 我已經閱讀了大多數相關問題,但是在這里我找不到我的問題。
您應該使用隱式意圖打開外部應用程序。 例如:
<activity android:name=".B_Activity" android:label="@string/app_name"
>
<intent-filter>
<action android:name="com.orr.con.projectb.SOME_ACTION"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
在第一個應用程序中:
Intent intent = new Intent();
intent.setAction("com.orr.con.projectb.SOME_ACTION");
context.startActivity(intent);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.