Reputation: 11
I'm working on setting a video wallpaper for Android, but I can't determine when it's successfully installed.
I tried to set broadcast receiver to listen service, but I cant know how to set Broadcast. This is a funtion of my service (extend from WallpaperService) to set video wallpaper
fun setToWallPaper(context: Context) {
val intent = Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER)
val component = ComponentName(context, VideoLiveWallpaperService::class.java)
intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, component)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(intent)
try {
WallpaperManager.getInstance(context).clear()
} catch (e: IOException) {
e.printStackTrace()
}
}
Upvotes: 1
Views: 96