home-assistant / home-assistant/android

command_webview should not relaunch application

Open
#5,381 5 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Kotlin
Stars
3.9k
Forks
1.1k
Avg merge
1d 12h
Merged PRs (30d)
81

Description

**Is your feature request related to a problem? Please describe.**
I'm trying to display the front door camera feed whenever a person is detected on the stairs. This works well, but switching the view via command_webview relaunches the already running companion app and introduces about 5 - 10 seconds latency. After some days the app seems to crash completely and needs to be manually restarted. That did not happen before.

**Describe the solution you'd like**
In my context it makes no sense to restart the already running HA companion app ... I just want to switch tabs. Not sure if there is any use case at all that requires multiple instances. If not, this could fix my problem:
```
android:launchMode="singleInstance"
```

alternatively what this guy suggested on stack overflow
```
In general you can use a combination of Intent.FLAG_ACTIVITY_SINGLE_TOP, Intent.FLAG_ACTIVITY_CLEAR_TOP, Intent.FLAG_ACTIVITY_REORDER_TO_FRONT and Intent.FLAG_ACTIVITY_NEW_TASK to accomplish what you want. However, which one (or ones) to use depends on the situation you have
```
https://stackoverflow.com/a/11555704

**Describe alternatives you've considered, if any**
I tried the solution above, but was not able to test it, because the push notifications require firebase configuration which I did not manage to get running.

**Additional context**
```
alias: Türkamera auf Tablet EG anzeigen wenn Person(en) erkannt
description: ""
triggers:
- trigger: numeric_state
entity_id:
- sensor.frontdoor_person_count
above: 0
conditions: []
actions:
- action: notify.mobile_app_tablet_eg
metadata: {}
data:
message: command_screen_on
alias: Wakeup Tablet
- alias: Switch to Frontdoor view
action: notify.mobile_app_tablet_eg
metadata: {}
data:
message: command_webview
data:
command: lovelace/frontdoor
- wait_for_trigger:
- trigger: numeric_state
entity_id:
- sensor.frontdoor_person_count
for:
hours: 0
minutes: 0
seconds: 5
below: 1
timeout:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- alias: Switch to Frontdoor view
action: notify.mobile_app_tablet_eg
metadata: {}
data:
message: command_webview
data:
command: lovelace/default_view
mode: single
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.