Does Google ActivityRecognitionApi IN_VEHICLE use GPS - android

My requirement is to detect if a person is driving. I am a bit confused with the Google ActivityRecognitionApi documentation.
Does "IN_VEHICLE" mean that the vehicle is in motion or can it be a stationary as well.
Does Google ActivityRecognitionApi "IN_VEHICLE" use GPS along with accelerometer?
If no, do we need to use GPS as well to detect if the vehicle is in motion?

Does "IN_VEHICLE" mean that the vehicle is in motion or can it be a stationary as well?
Based from DetectedActivity, IN_VEHICLE simply means that the device is in a vehicle, such as a car.
Does Google ActivityRecognitionApi "IN_VEHICLE" use GPS along with accelerometer? If no, do we need to use GPS as well to detect if the vehicle is in motion?
This statement from the ActivityRecognitionApi documentation gives a clear answer on how activities are being recognized using the API:
The activities are detected by periodically waking up the device and reading short bursts of sensor data. It only makes use of low power sensors in order to keep the power usage to a minimum. For example, it can detect if the user is currently on foot, in a car, on a bicycle or still.
You may want to also check this article which focuses on using the Google Play Services Activity Recognition API to determine if the user is running, walking, in a vehicle, biking, or remaining still.
Lastly, with regards to the use of GPS and accelerometer, I suggest that you please check Motion Sensors documentation wherein it provides several sensors that let you monitor the motion of a device.

Related

API to detect distance between Wear watch & Android phone?

In my application, we want to warn the user when he is at distance from Phone or watch.
We are scanning nearest nodes using APIs of wear OS.
Is there any way I can detect the distance between two such nodes?
Getting geolocation of both & calculate distance using formula is one possible way.
But aren't the APIs on wear OS has something which can detect distance using Bluetooth range or signal strength?
The best that's directly supported by the platform is the Node API's isNearby method, but that essentially just returns true iff the phone-watch connection is over Bluetooth rather than cellular or wifi. It doesn't give you anything resembling a real distance number.
Beyond that, you'd have to roll your own solution using GPS on both devices, as you mention. But that has a lot of downsides: complexity, reliability, and battery use are ones that immediately occur to me. Someday, you'll be able to get this kind of accuracy from the fused location provider using wifi, but probably not for some years.

Using the GPS to detect whether an android device is indoors

The app which i'm writing need to somehow detect if an android device is indoors or outdoors. My goal is to detect if the user left a certain building as soon as possible.
I tried to use the user location signals. I'm not initiating any GPS sampling since I don't want to waste too much battery power, so the only way to detect if a user left a building is to wait for him to be far enough from the place and then use location signals which were sampled by wifi or cell.
The problem is that it takes quite some time for me to detect that the user left the building.
I know that when a user is indoors, his GPS signal is weaker. Can I somehow use the GPS status to find out if the user is indoors or outdoors? Will it be wasteful as initiating a GPS location sample?
Thanks.
I don't think you can do what you want to do with the FusedLocationProvider as this uses WiFi and cell tower triangulation. You will need to use the LocationManager.
It is also difficult to detect if you're inside and as far as I know there is no definitive way of doing this. You can make informed guesses however.
In terms of detecting a "weak" GPS signal you have a few things you could check:
The number of satellites available to you. If a low number then you are either indoors or somewhere with poor satellite coverage.
The horizontal accuracy of a received GPS location. If this value is high it can be deemed as poor accuracy which could be because you're inside.
No location has been received for a period of time. This could be because you're inside.
Have you thought of doing other checks as well as GPS so if they're connected to WiFi it increases the likelihood of them being inside?

Android smart power management using sensor data

I'm working on an Android application that needs to scan nearby Wi-Fi access points on a regular basis. Currently the scan takes place every 2-3 minutes, which requires registering a BroadcastReceiver to capture the scan results, calling WifiManager's startScan method and processing the results (something that also requires network calls in my case). This loop consumes a lot of energy, and I want to improve my power consumption by implementing a smart power policy for the app.
Aside from scanning only on "busy hours" (for example, stopping the loop at night), I'm thinking about using the accelerometer through the SensorManager to detect whether the device is stationary (placed on a table) or in motion (in the user's pocket while walking, for example). Then, by determining if the device is moving, I can adjust the scan frequency (reduce when it is stationary, and increase when the device is in motion).
I have a few questions on the matter:
1) Will tracking accelerometer data on a regular basis be more power efficient than running the scan loop every 3-5 minutes? How much power will tracking the accelerometer really cost?
2) How can I determine if the device is stationary or in motion? I've seen many question online talking about detecting shakes and tilts, but there's not a lot of information about natural motion detection. Also, how frequently should I sample the sensor?
I think the best way is to use ActivityRecognitionApi class included in the google play sevices which is optimized for such goals. This class gives a method : requestActivityUpdates which is optimized to return device state with minimum consumption of power.
The activities are detected by periodically waking up the device and
reading short bursts of sensor data. It only makes use of low power
sensors in order to keep the power usage to a minimum.
I second Fouwad Wahabi’s answer to your question.
I would recommend taking another approach to the track accelerometer and your user’s activities. I’d integrate a free SDK (available online) such as:
1. Tranql
2. Neura
3. Atooma
Some of these SDK’s send you the details of the user’s activities as soon as they occur and use less than 1% of your battery.

Need to know if phone is FAR or CLOSE to user's ear while in a call

I want to track the phone's position while the user is in call. I don't want to register the proximity sensor for it because it's redundant and I don't want to count that sensor battery consumption on me, the system uses the proximity anyway when a call starts.
My question is how can I get the position ("far"/"close" in Android logs terminology) of the phone relative to the user's ear?
Thanks
Bush
As far as I know, the proximity sensor is the best way to check the distance from the user's face.
However, if you're willing to come up with some good algorithms, you could try using the accelerometer and the microphone. However, the microphone may not be available to two apps at once.
If the user's device is touching their face, there will be less accelerometer movement that varies from one direction to another. However, if the phone is held away, there will be some shaking. And if there is no change in the accelerometer readings at all, it is likely lying on a desk, and the user is talking on loudspeaker or using a headset.

Android Bluetooth Device Locator

How can I locate other BlueTooth devices that are using my app and show them on map, with range, exact location, like radar map.
The only way you could possibly do this is if your Bluetooth slave devices individually have the ability to track and report their location (e.g. GPS).
Otherwise it's not possible at all. The Bluetooth radio and antenna in your Android device will have no direction finding ability.
Possible design idea :
You want to implement this with the help of a webservice.
Make your app report its being used(may be you want to report at regular intervals and shutdown of app) along with location information (probably you want to use GPS, have a look at this : Obtaining User Location).
Make you radar app to read those information and prepare the map.
Cons :
Availability of GPS will affect your application
Accuracy is limited.

Categories

Resources