Ad
Schedule Auto Wallpaper Changing In Background
how can we set a background task to android so that at given time an image is loaded from URL and set as wallpaper
Ad
Answer
Use this code to set the wallpaper
WallpaperManager myWallpaperManager
= WallpaperManager.getInstance(getApplicationContext());
try {
myWallpaperManager.setResource(R.drawable.five);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
AND u need to addd this permission in your manfest
<uses-permission android:name="android.permission.SET_WALLPAPER" />
and you need JobDispatcher to runa task periodically.
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
Job myJob = dispatcher.newJobBuilder()
.setService(MyJobService.class)
.setTag("DAILY-MAIN-SYNC")
.setRecurring(true) // setRecurring
// don't persist past a device reboot
.setLifetime(Lifetime.FOREVER)
.setTrigger(Trigger.executionWindow(1, (int) TimeUnit.DAYS.toSeconds(1)))
.setExtras(myExtrasBundle)
.build();
dispatcher.schedule(myJob);
this job will run each day
now create MyJobService extends JobService
in in the
@Override
public boolean onStartJob(JobParameters job) { ....
write the code I wrote above.
Hope this will guide you to the right track.
Ad
source: stackoverflow.com
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View
Ad