2
public class ShortCurActivity extends Activity{ 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    final Button button = (Button)findViewById(R.id.b_start); 
    if(button != null){ 
    button.setOnClickListener(new View.OnClickListener() { 

     public void onClick(View paramView) { 
      Intent i = new Intent(ShortCurActivity.this, ServiceWallpaper.class); 
        startService(i); 
     } 
    }); 
    } 

} 

我只想知道我是否可以从活动启动一个动态壁纸服务。我试图使用意图,但它不起作用。一些设计师要我做了动态壁纸的快捷方式,使用户可以随时进行更改,他们希望自己的:(动态壁纸从活动开始一个动态壁纸服务

回答

0

似乎没有被任何以编程方式更改用户的LWP。

3
if (Build.VERSION.SDK_INT > 15) 
      { 
       i.setAction(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER); 
       String pkg = WallpaperService.class.getPackage().getName(); 
       String cls = WallpaperService.class.getCanonicalName(); 
       i.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, new ComponentName(pkg, cls)); 
      } 
      else 
      { 
       i.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER); 
      } 
      startActivityForResult(i, 0);``