ImTrung
ImTrung

Reputation: 93

Start a live wallpaper service from activity

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);
        }
     });
    }

}

I just want to know if I can start a live wallpaper Service from Activity. I have tried to use Intent but it does not work. Some Designers want me to make a shortcut for Live wallpaper so the user can change their live wallpaper whenever they want :(

Upvotes: 2

Views: 3925

Answers (2)

user1612529
user1612529

Reputation: 31

 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);``

Upvotes: 3

Garnet Ulrich
Garnet Ulrich

Reputation: 3009

There does not seem to be any way to programmatically change the user's lwp.

Upvotes: 0

Related Questions