Magnet Sensor

Post your questions and help other users.

Moderator: Martin

Post Reply
Moto1987
Posts: 30
Joined: 09 Apr 2016 13:02

Magnet Sensor

Post by Moto1987 » 29 Apr 2018 15:22

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

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Magnet Sensor

Post by Desmanto » 29 Apr 2018 17:15

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).
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Moto1987
Posts: 30
Joined: 09 Apr 2016 13:02

Re: Magnet Sensor

Post by Moto1987 » 29 Apr 2018 17:24

Thanks i will try it later and tell you if it works.

Moto1987
Posts: 30
Joined: 09 Apr 2016 13:02

Re: Magnet Sensor

Post by Moto1987 » 30 Apr 2018 18:25

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

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Magnet Sensor

Post by Desmanto » 03 May 2018 16:25

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply