0

单击 Daydream 应用程序的设置按钮关闭我的应用程序。请在 Manifest 文件中分配 -

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

我已阅读此处给出的解决方案。但这不适合我的语境。如果我走错了路,请指导我正确的方式。请告诉我我的代码哪里出错了。

这是我的日志猫 -

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

提前致谢。

4

1 回答 1

0

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

于 2013-09-26T14:52:02.783 回答