Detecting Driving
Moderator: Martin
Detecting Driving
I want to trigger certain flows when I start/stop driving. It's not clear to me how to do that. Can anyone help?
Thanks!
Thanks!
- digitalstone
- Posts: 342
- Joined: 21 Oct 2017 12:36
- Location: The Netherlands
Re: Detecting Driving
The first question you should ask yourself is, what "thing" would let my phone know that i'm going to drive in my car?
Do you hook it up to something like usb?
And would that be at particular times of the day/week?
Do you hook it up to something like usb?
And would that be at particular times of the day/week?
Phone: LG Nexus 5X (rooted vanilla Android 7.1.2)
Re: Detecting Driving
Hi,
maybe your want to have a look into this User Activity Trigger..
If your car has Bluetooth, this is the way to go.
Otherwise, you have to think about your real-life flow. Maybe something like "Wifi Disconnected from Homenetwork" -> "Wait for USB-Car-Charger" -> "We are in the car".
maybe your want to have a look into this User Activity Trigger..
If your car has Bluetooth, this is the way to go.
Otherwise, you have to think about your real-life flow. Maybe something like "Wifi Disconnected from Homenetwork" -> "Wait for USB-Car-Charger" -> "We are in the car".
Re: Detecting Driving
I'm testing flows that detect when the car's bluetooth connects/disconnects, but they go on & off all the time as if it's constantly connecting, disconnecting, and reconnecting. I could use a global variable that gets set to true on the first connect but I can't know which disconnect trigger will be the last one to then set the var to false.
I previously tried detecting the launch/closing of the Android Auto app but got the same behavior: start/stop over and over again.
I'm stymied.
I previously tried detecting the launch/closing of the Android Auto app but got the same behavior: start/stop over and over again.
I'm stymied.
Re: Detecting Driving
It shouldn't flapping like that. There can be some app interfering with the event. Can you add variable logger script to it to see what is going on during the flapping connect/disconnect? If you can spot the pattern, probably you can know which app is causing it. Of course it must be something related to bluetooth.
If the flapping is unavoidable, you can add trigger buffer to protect against the false trigger : viewtopic.php?f=5&t=7229
You can't prevent the flapping, but you can protect the main flow.
If the flapping is unavoidable, you can add trigger buffer to protect against the false trigger : viewtopic.php?f=5&t=7229
You can't prevent the flapping, but you can protect the main flow.
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.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Detecting Driving
If your smartphone has NFC module, then NFC tag is also an option. You just stick it somewhere in the car on the dashboard and just touch with your smartphone any time you enter your car to execute flow of your idea. Personally, I have one sticked onto smartphone holder which is permanently installed in my car, so everytime I put my smartphone into holder appropriate action fires up like starting google maps, music application etc... This is quite convenient and effective.
Another option as already mentioned is triggering by car bluetooth system found. The only disadvantage of this is whenever you are close to your car and not necessarily want to drive, the flow gets triggered regardless.
Another option as already mentioned is triggering by car bluetooth system found. The only disadvantage of this is whenever you are close to your car and not necessarily want to drive, the flow gets triggered regardless.
Re: Detecting Driving
NFC is a good option. I wish I have NFC on my phone, but I don't.
Another option is to use the "Scan Barcode" action triggered by a shortcut.
I generate my own barcode from online barcode generator websites, then stick the barcode inside my car.
I scan it and it starts all my car specific flows. It's a bit of a manual process, but with habit, it is quite fast and automatic for me.
I also stick another barcode at my office computer. When I come in to work, I scan barcode it, and it starts all my work specific flows.
Another option is to use the "Scan Barcode" action triggered by a shortcut.
I generate my own barcode from online barcode generator websites, then stick the barcode inside my car.
I scan it and it starts all my car specific flows. It's a bit of a manual process, but with habit, it is quite fast and automatic for me.
I also stick another barcode at my office computer. When I come in to work, I scan barcode it, and it starts all my work specific flows.
Re: Detecting Driving
@akela : I ever thought about the similar concept too, but using QRCode. But cancelled it because why we should open and scan the code again? Just simply use a simple shortcut at home screen to set all the flow state and variables 

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.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Detecting Driving
I've been doing more testing and I've found that I might have been misinterpreting what I saw. I now think the triggering is correct for the Bluetooth connect/disconnect and all should be well going forward.
Thanks for the help!
Thanks for the help!
Re: Detecting Driving
I agree with the second comment...
Graduated from Soran University with First Class Degree with Honours in Computer Science