系统墙纸应通过服务进行更改 [英] 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???
推荐答案
创建服务类
class WallpaperService extends IntentService {
@Override
protected void onHandleIntent(Intent intent) {
Timer progressTimer = new Timer();
timeTask = new ProgressTimerTask();
progressTimer.scheduleAtFixedRate(timeTask, 0, 1000);
}
private class ProgressTimerTask extends TimerTask {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
int currenMinutes = 0; // set your time here
changeWallpapers(currentMinutes);
}
});
}
}
private void changeWallpapers(int minutes) {
if(minutes == 1)
layout.setBackGround(Color.RED);
if(minutes == 2)
layout.setBackGround(Color.BLUE);
}
}
}
然后在需要的地方调用服务Intent
And then call your service Intent where your want
这篇关于系统墙纸应通过服务进行更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文