1

I have found plenty of tutorials on how to set as wallpaper an image, a png for instance. But what I am trying to do is make my wallpaper in code and then set it. This is because I want the user to be able to tweak the wallpaper (eg. choose background color etc). What I have so far is this:

public class Landscape extends AppCompatActivity {

ValueAnimator skyAnimator;

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

    skyAnimator = ObjectAnimator.ofInt(findViewById(R.id.sky), "backgroundColor", Color.rgb(0x00, 0x00, 0x4c), Color.rgb(0xae, 0xc2, 0xff));
    skyAnimator.setDuration(10000);
    skyAnimator.setEvaluator(new ArgbEvaluator());
    skyAnimator.setRepeatCount(ValueAnimator.INFINITE);
    skyAnimator.setRepeatMode(ValueAnimator.REVERSE);
    skyAnimator.start();
}

public void setWallpaper(View view) {
    Intent intent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
    intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, new ComponentName(this, Landscape.class));
    startActivity(intent);
}

Unfortunately, nothing happens when I click on setWallpaper. Is there a way of achieving this? Is it even possible?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Code Poet
  • 6,222
  • 2
  • 29
  • 50

0 Answers0