2014-05-12 2 views
0

안드로이드를 사용하여 주요 활동에 라이브 벽지를 직접 표시하는 방법은 무엇입니까?주요 활동에 라이브 벽지를 직접 표시하는 방법은 무엇입니까?

나는 한 화면,

샘플 싶어 : 나는 라이브 배경 화면 "설정 바탕 화면"라이브 화면 직접 원하는 프로그램을 클릭하면

하기!

샘플 봐 그림하시기 바랍니다 를 [입력 이미지를 여기에 설명] [1]

http://i.stack.imgur.com/IFzTy.png

나는 벽지 목록을 원하지 않는다, 나는 워싱턴하지 않습니다 nt 주요 활동 기타 버튼 .. 원하는 경우 프로그램을 클릭하면 라이브 배경 화면 "라이브 배경 설정"라이브 화면으로 이동합니다.

죄송합니다, 제 영어는 좋지 않습니다.

어떻게하면 되나요? 내가 총 4 자바 코드가 나에게

도와주세요 :

Animationwallpaper.java Bokehrainbowcircle.java Bokehrainbowwallpaper.java MainActivity.Java 버튼을 누르면

And My manifest code: 

<?xml version="1.0" encoding="utf-8"?> 

<manifest 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.sample.livewallpaper.bokehrainbow" android:versionCode="1" 
      android:versionName="1.0"> 

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

    <!-- We need to request a permission to install a shortcut icon --> 
    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> 

    <application 
     android:label="@string/wallpapers" 
     android:icon="@drawable/icon"> 

     <service 

      android:name="com.funnyphotoshoppictures.BokehRainbowWallpaper" 
      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="@layout/bokeh" /> 
     </service> 


     <activity 

      android:name="com.funnyphotoshoppictures.AnimationWallpaper" 
      android:theme="@android:style/Theme.WallpaperSettings" 
      android:exported="true"> 
     </activity> 

     <!-- Register the activity in the manifest --> 
     <activity 
      android:name="com.funnyphotoshoppictures.MainActivity" 
      android:theme="@android:style/Theme.WallpaperSettings" 
      android:screenOrientation="portrait" 
      android:icon="@drawable/icon"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 

    </application> 
    <supports-screens 
     android:smallScreens="false" 
     android:normalScreens="true" 
     android:largeScreens="true" /> 
</manifest> 

답변

2

후를,이 코드를 실행합니다. "시도"안의 코드는 귀하의 타겟 라이브 벽 종이에 정확하게 점프하는 것을 의미하지만 귀하의 모든 라이브 배경 화면의 갤러리는 아닙니다. 그것은 귀하의 요구 사항을 충족 것으로 보인다하지만 그것은 단지 안드로이드 4.1 작동합니다.

"catch"안의 코드는 전화가 "try"의 코드를 지원하지 않으면 모든 라이브 배경 화면의 갤러리로 점프하는 것을 의미합니다.

희망, 그것은 당신을 도울 수있다 : 당신의 styles.xml에서

try{ 
     Intent intent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER); 
     intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, 
     new ComponentName(MainActivity.this, com.abc.YourMainProgram.class)); 
     startActivity(intent); 
} 
catch(Exception e){ 
     Intent intent = new Intent(); 
     intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER); 
     startActivity(intent); 
} 
1

사용이 :

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat"> 
    <item name="android:windowBackground">@android:color/transparent</item> 
    <item name="android:colorBackgroundCacheHint">@null</item> 
    <item name="android:windowShowWallpaper">true</item> 
    <item name="android:windowTranslucentNavigation">true</item> 
    <item name="android:windowTranslucentStatus">true</item> 
</style> 
관련 문제