2015/04/11

Declaring DeviceListActivity in AndroidManifest.xml

Logcat output

04-10 16:47:14.546  13580-13580/com.example.wei_hsiunghuang.my1stbluetooth E/AndroidRuntime FATAL EXCEPTION: main
    android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.wei_hsiunghuang.my1stbluetooth/com.example.wei_hsiunghuang.my1stbluetooth.DeviceListActivity}; have you declared this activity in your AndroidManifest.xml?
    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1545)
-----------------------------------------------------------------------------------------------------------------
The DeviceListActivity is indeed missing in the AndroidManifest.xml.

AndroidManifest.xml – Original Version

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   
package="com.example.wei_hsiunghuang.my1stbluetooth" >

    <
uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
    <
uses-permission android:name="android.permission.BLUETOOTH"/>

    <
application
       
android:allowBackup="true"
       
android:icon="@mipmap/ic_launcher"
       
android:label="@string/app_name"
       
android:theme="@style/AppTheme" >
        <
activity
           
android:name=".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>
    </
application>

Check and make sure that “DeviceListActivity.java” is in the project before adding the declaration for it in AndroidManifest.xml



AndroidManifest.xml – Updated Version

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   
package="com.example.wei_hsiunghuang.my1stbluetooth" >

    <
uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
    <
uses-permission android:name="android.permission.BLUETOOTH"/>

    <
application
       
android:allowBackup="true"
       
android:icon="@mipmap/ic_launcher"
       
android:label="@string/app_name"
       
android:theme="@style/AppTheme" >
        <
activity
           
android:name=".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=".DeviceListActivity"
           
android:label="@string/select_device"
           
android:theme="@style/DialogTheme" />

    </
application>

</
manifest>

---------------------------------------------------------------------------------------------------------------------------

The @style/DialogTheme is defined in res/values/styles.xml.

Styles.xml - Original Version

<resources>
   
<!-- Base application theme. -->
   
<style name="AppTheme" parent="Theme.Sherlock"/>
</
resources>

---------------------------------------------------------------------------------------------------------------------------

Styles.xml - Updated Version

<resources>
   
<!-- Base application theme. -->
   
<style name="AppTheme" parent="Theme.Sherlock"/>
    <
style name="DialogTheme" parent="@android:style/Theme.Dialog"/>
</
resources>


2 comments: