4

I've created a Wear OS app. It has a service running in the foreground. I need to have the app always executing. When I restart the watch the app doesn't start executing again. How can I automatically relaunch the app?

It's my first app for Wear OS and I don't know how to search for this.

Thank you!

TofferJ
  • 4,678
  • 1
  • 37
  • 49
lmano
  • 41
  • 1

1 Answers1

0

I'm not 100% certain, and it's a bad idea for an app to do in most cases. But I believe

https://developer.android.com/reference/android/Manifest.permission#RECEIVE_BOOT_COMPLETED

This will wake up your broadcast receiver so you can run some code, but as you discovered you are probably restricted against starting an activity.

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

Yuri Schimke
  • 12,435
  • 3
  • 35
  • 69
  • Receiver is called but not able to open the app using the intent. Also not getting any error. – SANAT Nov 23 '22 at 12:41
  • Yep, that makes sense. Probably relates to background restrictions https://developer.android.com/guide/components/activities/background-starts I guess posting a notification from that boot event is the most you can do? – Yuri Schimke Nov 24 '22 at 18:51
  • I have already tried https://stackoverflow.com/a/57869617/2024527 by which I am able to generate the notification but not able to open the app. – SANAT Nov 25 '22 at 05:51