Skip to content Skip to sidebar Skip to footer

System Wallpaper Should Change Through Service

my application requires a service that changes the system wallpaper in a particular time interval how should I implement this, please help???

Solution 1:

Create your service class

classWallpaperServiceextendsIntentService {

    @OverrideprotectedvoidonHandleIntent(Intent intent) {
        TimerprogressTimer=newTimer();
        timeTask = newProgressTimerTask();
        progressTimer.scheduleAtFixedRate(timeTask, 0, 1000);
    }

    privateclassProgressTimerTaskextendsTimerTask {
        @Overridepublicvoidrun() {
            runOnUiThread(newRunnable() {
                @Overridepublicvoidrun() {
                    intcurrenMinutes=0; // set your time here
                    changeWallpapers(currentMinutes);
                }
            });
        }
    }

    privatevoidchangeWallpapers(int minutes) {
        if(minutes == 1)
            layout.setBackGround(Color.RED);
        if(minutes == 2)
            layout.setBackGround(Color.BLUE);
    }
}

}

And then call your service Intent where your want

Solution 2:

Well, I have implemented this function. I register an Alarm in the system and connect it to a BroadcastReceiver. When the BroadcastReceiver is triggered, in the OnReceive() method, you can set a wallpaper for the system.

Post a Comment for "System Wallpaper Should Change Through Service"