Reputation: 11
I'm working with WallpaperService in my Android project, and when the service starts, it presents options to the user to set the wallpaper either for the home screen or both the home and lock screens. I want to modify this behavior so that only one option is available, specifically setting the wallpaper for both the home and lock screens by default. How can I achieve this?
my code is like
fun setToWallPaper(context: Context) {
val intent = Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER).apply {
putExtra(
WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
ComponentName(context, Mp4WallpaperService::class.java)
)
flags = Intent.FLAG_ACTIVITY_NEW_TASK
}
context.startActivity(intent)
try {
WallpaperManager.getInstance(context).clear()
} catch (e: IOException) {
e.printStackTrace()
}
}
should show only one option home and lock screen
Upvotes: 1
Views: 33
Reputation: 36
Change the way you are applying your wallpaper. Create a Chooser like this:
context.startActivity(Intent.createChooser(intent, "Set as:"))
Using context.startActivity(intent)
directly will apply wallpaper to either home screen or lock screen.
Upvotes: 0