动态壁纸“设置壁纸”不起作用

时间:2013-07-04 15:53:47

标签: android live-wallpaper

我的Lv有问题。我使用以下代码创建了启动器活动:

Toast toast = Toast.makeText(this, "Choose Photo Live Wallpaper from the list to start the Live Wallpaper.",Toast.LENGTH_LONG); toast.show(); Intent intent = new Intent(); intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER); startActivity(intent); finish();

在我的清单中我用它声明它:

<activity android:name=".Launcher" android:label="@string/app_name"
    android:screenOrientation="portrait" 
    android:icon="@drawable/iconn">
    <intent-filter>
         <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
          <action android:name="android.intent.action.CREATE_SHORTCUT" />
    </intent-filter>
</activity>

它正在工作,但当我点击设置壁纸启动器活动再次启动,我不知道为什么。 Logcat给我这个错误:

chanel '4143dd60 org.me.project.serviceLv (client) ~ Publisher close input chanell or an error ocured event=0x8

感谢您的帮助

这是我的清单文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.gp.project.photogallerylivewallpaper"
android:versionCode="2"
android:versionName="1.1" >

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="14" />

<uses-feature android:name="android.software.live_wallpaper" />

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

<application>
    <service
        android:name=".GalleryWallpaper2"
        android:label="Photo LiveWallpaper"
        android:permission="android.permission.BIND_WALLPAPER" >
        <intent-filter android:priority="1" >
            <action android:name="android.service.wallpaper.WallpaperService" />
        </intent-filter>

        <meta-data
            android:name="android.service.wallpaper"
            android:resource="@xml/wallpaper" />
    </service>

    <activity
        android:name=".Settings"
        android:exported="true"
        android:launchMode="singleTask"
        android:theme="@android:style/Theme.Light.NoTitleBar" />
    <activity
        android:name=".Launcher"
        android:icon="@drawable/iconn"
        android:label="@string/app_name"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />

            <action android:name="android.intent.action.CREATE_SHORTCUT" />
        </intent-filter>
    </activity>
</application>

2 个答案:

答案 0 :(得分:0)

发布更多logcat。同样对于动态壁纸,您需要在Android Manifest中定义一个服务,其中包含一个Intent过滤器。例如: -

      <service android:name="packagename.LiveWallpaper" //LiveWallpaper is the class  name
        android:label="@string/app_name"
        android:icon="@drawable/icon"
        android:permission="android.permission.BIND_WALLPAPER">

        <intent-filter>
            <action android:name="android.service.wallpaper.WallpaperService" />
        </intent-filter>
        <meta-data android:name="android.service.wallpaper"
            android:resource="@xml/livewallpaper" />    
    </service>

答案 1 :(得分:0)

尝试更改此活动代码

   <activity
    android:name=".Settings"
    android:exported="true"
    android:launchMode="singleTask"
    android:theme="@android:style/Theme.Light.NoTitleBar" />

这个......

   <activity
    android:name=".Settings"
    android:exported="true"
    android:launchMode="singleTask"
    android:theme="@android:style/Theme.NoDisplay" />

我认为这确实有用......