单击Android Daydream服务中的设置按钮停止应用程序

时间:2013-09-25 13:31:48

标签: java android dreamservice

点击白日梦应用程序的设置按钮关闭我的应用程序。请在清单文件中使用allok -

 <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>

相反,empty_settings.java类应该打开。

我已阅读here给出的解决方案。但这不适合我的背景。如果我走错路,请以正确的方式指导我。请告诉我我的代码出错了。

这是我的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

这是我的清单文件 -

<?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>

这是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" />

提前致谢。

1 个答案:

答案 0 :(得分:0)

我现在明白了。我的错误是,我在dream_info.xml文件中输错了包名。现在我的应用程序运行正常。