Page 1 of 1
Magnet Sensor
Posted: 29 Apr 2018 15:22
by Moto1987
Hallo, ich habe eine Magnethalterung fürs Handy und möchte, sobald das Handy am halter dran ist, dass "Android Auto" automatisch gestartet wird.
Ich habe den Flow soweit schon erstellt, mit dem Anfang WLAN getrennt mit der darauf folgenden condition "Magnet Sensor" und dann Action App starten. Es funktioniert auch aber wenn die Halterung mal nicht da ist (dementsprechend fehlt die Bestätigung beim sensor) wird der Flow nicht nochmal ausgeführt, wenn ich es anstecken an die Halterung.
Ich möchte, dass der sensor (condition) zum Beispiel alle 30 Sekunden prüft, ob ein Magnetfeld vorhanden ist und dann dementsprechend die App "Android Auto" startet.
Wie stelle ich das an? Bisher habe ich es leider nicht hinbekommen.
Grüße Moto1987
Re: Magnet Sensor
Posted: 29 Apr 2018 17:15
by Desmanto
The Trigger is Wifi Disconnected, it happens only once. So if at that one chance, your phone doesn't detect the magnet, the flow won't detect it anymore. You can solved it by using loop. Put Action sleep 30 seconds after the magnet check is false, and followed by Condition Execution Count, let's say 10. False branch, looped back to the condtion magnet sensor again. Which mean the flow repeatly check for the magnet sensor for 10 times after the wifi disconnected. But this is not efficient.
The better way to do it, is to separate the flow into 2 flows. Since both wifi disconnected and Magnet sensor are events here, not a condition.
Flow 1
Trigger : Wifi Disconnected
Action : Set Flow State : Flow 2 > Enabled
Flow 2
Trigger : Magnetic Field Sensor
Action : Set whatever the Android Auto
Action : Set Flow State : Flow 2 > Disabled
Enable only Flow 1. So once wifi is disconnected, Flow 1 will enable Flow 2. The Flow 2 will start to check for the magnet. When it detects the magnet, it will start the android auto and then disable itself (since the job is finished).
Re: Magnet Sensor
Posted: 29 Apr 2018 17:24
by Moto1987
Thanks i will try it later and tell you if it works.
Re: Magnet Sensor
Posted: 30 Apr 2018 18:25
by Moto1987
I have testet it and it worked. Now i want, when I disconnect the phone from the Magnet that "Android Auto" is closing but I can't find the right way. I have made an Action with kill App, an Action with kill App Prozess and the last try was with send Broadcast but nothing helped.
My phone is rooted so i have a better chance to solve this problem.
The package name is following.
com.google.android.projection.gearhead
Thanks
Greetings Moto1987
Re: Magnet Sensor
Posted: 03 May 2018 16:25
by Desmanto
Ooops, I miss this thread yesterday. You can't kill foreground app. You need to switch to another app or go to home screen and try to kill it from there. Or you can simply just go to home screen and let android RAM management take care of the app itself. Unless the app really drain battery on background, I see no reason to kill it immediately.