Background
Suppose I have a relatively simple live wallpaper app which shows simple content via Canvas, by using surfaceHolder.lockCanvas()
(sample here).
The live wallpaper class (that extends WallpaperService
) has to have an Engine returned to it just once via onCreateEngine
function.
The problem
Things get more complicated when I want to support more complex content, such as videos. For this, I've found this nice library:
https://github.com/AlynxZhou/alynx-live-wallpaper/
The library uses its own implementation of an Engine class, which is of OpenGL, to show video content.
Sadly, as it seems, there is no way on Android to switch between Engine instances during runtime.
What I've found
-
I tried to call
stopSelf
, but as the Service is bound to the OS, it's not possible. I also tried to overrideonBind
, but I can't because it's marked asfinal
. I also don't see any possible reflection solution. -
I think the only possible way to do it that I've found, is to do one of the least recommended things on Android: calling
System.exit()
on the process that the live wallpaper uses. This causes it to restart, and re-create the Engine it was supposed to use. -
I could probably create a new class of a live wallpaper in the same app, but then the user will have to choose it again, which is a bad UX and I wish to avoid it.
The question
Is there any way to switch Engine during runtime for a live wallpaper app? Any workaround, even, other than what I've found?
from Is it possible to switch between Engins-classes on live wallpaper?
No comments:
Post a Comment