How to declare and set buttons in a live wallpaper using Kotlin and Android Studio

Viewed 267

I'm trying to work my way into Kotlin, and AndroidStudio 4.01. I've got several questions in this regard.

1.) Suppose my application is supposed to be a live wallpaper (with some settings that you can call). This live wallpaper is supposed to be updated every second (by a service?) How am I to declare this (service?) within the manifest?

2.) How can my app get access to the wallpaper? E. g. how can I place a button onto the wallpaper that leads to the settings window?

1 Answers

Create your own wallpaper using wallpaper service. Android support implementing our own live wallpaper by extending. Follow link to get more details about WallpaperService.

Once you implement wallpaper service you can draw your own graphics in window In same way you can draw your button on canvas on desired location. Implement on touch listener on your canvas and listen for button coordinates. Use accessibility service to launch your activity from the wallpaper service. You have to enable accessibility for your app before loading your wallpaper in system. This is one way to do it. You can find more ways on link bellow.

https://developer.android.com/guide/components/activities/background-starts

Related