2013-07-04 106 views
0

我有我的問題。我創建發射活動給它,使用此代碼:動態壁紙「設置壁紙」不工作

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> 

回答

0

發表您更多的logcat中的。對於動態壁紙,您需要在Android Manifest中定義一個包含Intent Filter的服務。例如: -

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

我添加了所有清單。 Logcat僅顯示此錯誤 – kPawel

+0

放置一個嘗試並捕捉畫布上繪製對象的代碼。例如: - Canvas canvas = null; 嘗試{canvas} = surfaceHolder.lockCanvas(null); synchronized(surfaceHolder) { onDraw(canvas); (canvas!= null) { } surfaceHolder.unlockCanvasAndPost(canvas); } } catch(Exception e){ e.printStackTrace(); } – user2125722

+0

但normaly lv正常工作。問題是當我使用啓動器。 – kPawel

0

試圖改變這種acitivty代碼

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

我認爲這將真正的工作....