0

am doing a part of my project which will create a button, or shortcut on android home screen so that when you click, it will turn screen off (yeah, sound like some others app on CH play) am finished the turn screen-off part, but now dont know how to make an icon in the home screen. I've tried to write all the code in the main activity and change all the backgrounds to black, so when user click on the app, all they see is just black, and they though it already locked, but doing this way is not smart, since there is a delay when app start and user see white screen with navigation bar. I want it to turn off immediately. What is the correct way to do this? i searched on google but didnt find anything useful, maybe am not using right keyword

  • [here](https://stackoverflow.com/questions/9561320/android-how-to-turn-screen-on-and-off-programmatically) you can see many ways to do it. (: hope it helps – Igor Romcy Oct 23 '18 at 02:02
  • ty but this link only guide how to the turn screen off, i've already finished that part. what i need is how to create a button on home screen for that – Euphoria Celestial Oct 23 '18 at 02:05
  • 1
    so, you need to create a widget for your app and , take a look here: https://github.com/google-developer-training/android-advanced/blob/master/AppWidgetSample/app/src/main/java/com/example/android/appwidgetsample/NewAppWidget.java – Igor Romcy Oct 23 '18 at 02:12

0 Answers0