簡體   English   中英

動態壁紙“設置壁紙”不起作用

[英]Live Wallpaper “set wallpaper” not working

我的呂先生有問題。 我使用以下代碼為其創建啟動器活動:

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>

發布更多您的logcat。 同樣對於動態壁紙,您需要在Android清單中定義一個服務,其中包含一個意圖過濾器。 例如:

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

嘗試更改您的此活動代碼

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

我認為這真的可以。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM