![](/img/trans.png)
[英]Fatal Exception: android.content.ActivityNotFoundException: No Activity found to handle Intent
[英]Android Exception Intent, activity not found
我目前正在使用android studio,我已將我的活動放入清單文件中,我相信我正確地調用它。 我不斷收到此錯誤:
引起: android.content.ActivityNotFoundException: Unable to find explicit activity class {/com.ca.android.easycall.customers1}; have you declared this activity in your AndroidManifest.xml?
android.content.ActivityNotFoundException: Unable to find explicit activity class {/com.ca.android.easycall.customers1}; have you declared this activity in your AndroidManifest.xml?
這是我的電話:
Intent actCustomers1 = new Intent(this, customers1.class);
startActivity(actCustomers1);
這是我的清單:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ca.android.easycall"
android:versionCode="1"
android:versionName="1.0" >
<permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.ca.android.easycall.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".customers1"
android:label="@string/title_activity_customers1" >
</activity>
<activity
android:name=".customers2"
android:label="@string/title_activity_customers2" >
</activity>
</application>
</manifest>
根據您發布的內容,您的類customers1
似乎未在com.ca.android.easycall
包中com.ca.android.easycall
當你有像android:name=".customers1"
這樣的東西時,Android編譯器會嘗試用軟件包名稱package="com.ca.android.easycall"
,因此它變為com.ca.android.easycall.customers1
引自Android官方文檔 :
安卓:名稱
實現活動的類的名稱,Activity的子類。 屬性值應該是完全限定的類名(例如,“com.example.project.ExtracurricularActivity”)。 但是,作為簡寫,如果名稱的第一個字符是句點(例如“.ExtracurricularActivity”),則它將附加到元素中指定的包名稱。
但是因為你得到了錯誤日志:
Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {/com.ca.android.easycall.customers1}; have you declared this activity in your AndroidManifest.xml?
所以它必須是customers1未聲明或customers1不在com.ca.android.easycall
包中
試試這個,
<activity
android:name="com.ca.android.easycall.customers1"
android:label="@string/title_activity_customers1" >
</activity>
<activity
android:name="com.ca.android.easycall.customers2"
android:label="@string/title_activity_customers2" >
</activity>
請編輯您的Manifest.xml
如下所示:
<activity
android:name="com.ca.android.easycall.customers1"
android:label="@string/title_activity_customers1" >
</activity>
<activity
android:name="com.ca.android.easycall.customers2"
android:label="@string/title_activity_customers2" >
</activity>
我希望這有幫助。
檢查活動文件頂部的包。 也許這些活動的包裝與您的應用程序不同。
如果不同,請將其更改為清單com.ca.android.easycall中的名稱
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.