简体   繁体   中英

Clicking on settings button in Android Daydream service stopping the application

Clicking on settings button of daydream application closing my application. Please have allok at the Manifest file -

 <application android:label="Bouncing Logo">

    <activity
        android:name="com.example.optionsmenuexample.empty_settings"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.empty_settings" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity> 


        <service
        android:name=".BouncerDaydream"
        android:exported="true"
        android:label="Bouncing Logo new">
        <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="android.service.dreams.DreamService" />
        </intent-filter>
        <meta-data
            android:name="android.service.dream"
            android:resource="@xml/dream_info" />
    </service>

</application>

Instead, empty_settings.java class should open up.

I have read the solution given here . But that did not suit my context. Please guide me the right way, if I am going in a wrong way. Please tell me where my code gone wrong.

This is my logcat -

09-26 10:16:46.807: E/AndroidRuntime(2036): FATAL EXCEPTION: main
09-26 10:16:46.807: E/AndroidRuntime(2036): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.app/com.example.app.empty_settings}; have you declared this activity in your AndroidManifest.xml?
09-26 10:16:46.807: E/AndroidRuntime(2036):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at android.app.Activity.startActivityForResult(Activity.java:3390)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at android.app.Activity.startActivityForResult(Activity.java:3351)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at android.app.Activity.startActivity(Activity.java:3587)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at android.app.Activity.startActivity(Activity.java:3555)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at com.android.settings.DreamBackend.launchSettings(DreamBackend.java:208)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at com.android.settings.DreamSettings$DreamInfoAdapter$2.onClick(DreamSettings.java:327)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at android.view.View.performClick(View.java:4240)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at android.view.View$PerformClick.run(View.java:17721)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at android.os.Handler.handleCallback(Handler.java:730)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at android.os.Looper.loop(Looper.java:137)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at android.app.ActivityThread.main(ActivityThread.java:5103)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at java.lang.reflect.Method.invokeNative(Native Method)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at java.lang.reflect.Method.invoke(Method.java:525)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-26 10:16:46.807: E/AndroidRuntime(2036):     at dalvik.system.NativeStart.main(Native Method)
09-26 10:16:46.817: W/ActivityManager(1226):   Force finishing activity com.android.settings/.SubSettings

And this is my Manifest file -

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.optionsmenuexample"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:targetSdkVersion="17" android:minSdkVersion="17"/>


<application android:label="Bouncing Logo">

    <activity
        android:name="com.example.optionsmenuexample.empty_settings"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.empty_settings" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity> 


        <service
        android:name=".BouncerDaydream"
        android:exported="true"
        android:label="Bouncing Logo new">
        <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="android.service.dreams.DreamService" />
        </intent-filter>
        <meta-data
            android:name="android.service.dream"
            android:resource="@xml/dream_info" />
    </service>

</application>

This is the dream_info.xml :-

<!-- res/xml/dream_info.xml -->
<?xml version="1.0" encoding="utf-8"?>
<dream xmlns:android="http://schemas.android.com/apk/res/android"
    android:settingsActivity="com.example.app/.ExampleDreamSettingsActivity" />

Thanks in advance.

I got it now. My mistake was, I mistyped the package name in dream_info.xml file. Now my app is working fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM