Android: How do you start a wallpaperservice from a button?
<p>I have a test live wallpaper that I wish to start from an activity. At the moment, it immediately finds itself in the live wallpaper chooser as I run the project on my emulator. Having searched everywhere, I still can't find a way to make it show up there only after a button in my main activity is pressed.</p>

<p>I tried introducing a static boolean in my main activity, isnotpressed, and setting it to false in the button onClick(). Then I used stopSelf() in my wallpaperservice class while isnotpressed is true. Unfortunately, none of this was to any avail and I don't think I'm going about it in the right way anyway. I also tried <a href="http://stackoverflow.com/questions/9081258/start-a-live-wallpaper-service-from-activity">this</a>, but it didn't work either. Any help would be deeply appreciated here.</p>

<p>Here's the main activity:</p>

<pre><code>public class TestProjectActivity extends Activity{

static boolean isnotPressed;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    isnotPressed = true;

final Button b1 = (Button) findViewById(R.id.button1);

b1.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        isnotPressed = false;
    }
});

}
</code></pre>

<p>}</p>

<p>And here's part of the wallpaperservice:</p>

<pre><code>public class MyWallpaperService extends WallpaperService {




@Override
public void onCreate() {
    // TODO Auto-generated method stub
    super.onCreate();

    while(TestProjectActivity.isnotPressed){stopSelf();}


}
</code></pre>
