0

I need help regarding Trusted Web Activity. My app works fine, but I need to add a function that keeps the screen awake without user interaction.

I am converting my website into a mobile application using Trusted Web Activity through Android Studio, but how can I keep the Trusted Web Activity screen awake while the user is using app but not interacting. Trusted Web Activity is not using an Android Activity and XML layouts, so it's not possible to use the Android Wake Lock API. How can I implement in the Trusted Web Activity or the web application?

DenverCoder9
  • 2,024
  • 11
  • 32
Codex999
  • 11
  • 1
  • Can you clarify the question? The screen will be awake while the user is interacting with it, so I'm guessing the goal is to keep it awake without user interaction, with a screen lock. Is this right? – andreban Nov 11 '20 at 08:20
  • yes, when user opens app the screen will keep awake until user close app manually. Plz guide if you know any solution thanks – Codex999 Nov 11 '20 at 19:48
  • 1
    You can use the Wake Lock API for this: https://web.dev/wake-lock/ – andreban Nov 12 '20 at 09:08
  • Thank you so much for the reply brother i am new bee how i use this please guide me thanks – Codex999 Nov 16 '20 at 05:20

1 Answers1

2

The Trusted Web Activity is like a browser tab without UI. The same web APIs that work in the browser should also work when running in the Trusted Web Activity mode.

Having said that, web Wake Lock API, available web applications, can be used prevent the screen from turning off on the web app. The linked article provides instructions on how to use it.

andreban
  • 4,621
  • 1
  • 20
  • 49