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.
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 this, but it didn't work either. Any help would be deeply appreciated here.
Here's the main activity:
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;
}
});
}
}
And here's part of the wallpaperservice:
public class MyWallpaperService extends WallpaperService {
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
while(TestProjectActivity.isnotPressed){stopSelf();}
}