Detect car parking efficiently on Android - android

I'm currently trying to detect when a car is parked via Android.
I was thinking of using the Android Detected Activities (https://developers.google.com/android/reference/com/google/android/gms/location/DetectedActivity) and detect a switch between IN_VEHICLE and ON_FOOT. But it means polling the device regularly so it's not really power efficient.
Do you think it's reliable enough ? Also, maybe there is a better solution ? What do you think ?
I also think about using Bluetooth and detect when the car's bluetooth is unpaired but everybody doesn't use Bluetooth.

I've used the ActivityRecognitionApi in one app, and it's fairly accurate. You are not "polling" the device, but rather subscribe to activity changes. This means there's really no overhead beyond what the phone is doing anyway.

Related

How to detect if two Android devices are near each other without using GPS?

I am planning a social app that needs a functionality to detect when two people are really close to each other, and preferably something that would be hard to cheat. I know I could use GPS but since there are GPS spoofing apps and the accuracy is not as narrow as I would need (for instance, two people on the same building but many floors apart should yield negative) I wanted to see if I could do it through WiFi or Bluetooth.
Is it possible to have two Android devices detect each other on the same wifi network from an app? No other information besides their presence is necessary.
I know Bluetooth can easily be done if the devices agree on the connection everytime. But I needed automatic detection, meaning the devices would accept the connection only once, and everytime they get close to each other the detection would be automatic without asking for permissions, and without requiring one of them to perform any actions to scan for bluetooth devices. I assume this is not possible for privacy reasons, right? Although no exchange of data is necessary, just the presence.
If anyone has any suggestions of other ways to achieve this, feel free to suggest. I don't need details about the code, just to know what is possible and what isn't and what do I need to look into (for instance libraries or components from the sdk).
I know detecting devices unconditionally is very unlikely to exist, for obvious reasons, but what I am looking for should go through an initial "handshake" or permission between the two devices, in order to enable the detection to happen (over a limited time window of maybe a couple of days), so I guess it may be possible, although I couldn't find anything.

Android code to find when antenna is hot due to my or any other app

I am new to android. I want to detect programmatically when mobile antenna is hot, meaning, I want to find when there is lot of n/w activity going on due to my or any other app, in general, in a programatic way as part of my business logic. Can some one share code snippet to figure this out. Thanks!
There is no tempature sensor on antenna, unless it is a custom device. Even if there is this information probably will not going to be available at application layer, because of security, even if it's available antenna would not get that hot from transferring data, even if it heats up, you wouldn't be able to detect it because big enviromental changes, it is not the same in equator and in Nordic countries.
To sum up, it is impossible to do that

Android: How to send and receive signals from a phone

I wanted to check if this is possible, i looked around in the net and i didn't find one answer.
Is it possible to use a phone via app to send a signal into a circuit and to receive the same signal back in the app?
Basically is there a library that i can use to work with such signals?
Thanks.
A phone, even smart, is not really intended to control an electrical circuit by sending it signals.
To do this comfortably, you need GPIO, ie pins whose you can control the output.
Your best bet is probably to buy yourself an Arduino, and to have it communicate with your phone over bluetooth.
You'll most likely have to develop your own application, as well as the program for the Arduino.
You could also have a look at the Raspberry, as it offers GPIO as well.
It might be a good tool for managing another circuit, but it all depends on what you exactly want to achieve.

Android: Detect position of another phone relative to your phone

An unusual question, but just something that randomly popped into my head.
Wondering if anybody had given this some thought with the current day technology.
It'd might be a pretty neat feature for a multiplayer game.
I know NFC's can detect another device in a nearby proximity, but does it have the ability to detect what angle the device is?
I'm talking about nearby positioning, like within bluetooth or wifi connectivity range.
Nothing related to using GPS or the internet.
No, NFC is for two devices in close proximity to each other, usually by no more than a few centimeters, (almost touching each other). It can't be used in multiplayer games unless it involves bumping the two phones together

Explicitly Managing WiFi Power Consumption in Android

Background
I'm developing a research application that runs on Android phones. In short, the application runs so long as the phone is on and periodically takes information from many components and sensors on the phone. The application is to disturb the user as little as possible. That being said, it's draining the battery far too quickly and forces the user to recharge every day. This simply won't do.
To try and figure out how to improve the situation, a colleague also working on the application let the application run for a long period of time and noticed that the biggest battery hog is WiFi. My current idea is to manually shut off WiFi when it's not in use in an attempt to save power. AFAIK, Android uses PSM for WiFi to accomplish this to some end, but it doesn't seem to be enough.
Problem
Is there a way to "ramp up" Android's PSM? Or, if there is not as this question suggests, is there any way that I can safely turn WiFi on and off without adversely affecting the user? I.e., is there a way to tell which applications are using WiFi and turn it off when none are? Do standard applications - such as the web browser and email clients - use WiFi locks to prevent WiFi from being turned off when they are working?
Any advice on where to start in solving this problem are greatly appreciated. Information on how Android's PSM works, how long it takes for it to take effect, or any information relevant to the problem are very welcome.
Thanks for your time!
Is there a way to "ramp up" Android's PSM?
Not via the Android SDK.
I.e., is there a way to tell which applications are using WiFi and turn it off when none are?
The OS does this already.
Do standard applications - such as the web browser and email clients - use WiFi locks to prevent WiFi from being turned off when they are working?
Some probably do. You are welcome to search the Android source code and find out. Of course, bear in mind that there are no "standard applications" -- I presume you are thinking of the ones that are part of the Android open source project.
Any advice on where to start in solving this problem are greatly appreciated.
Find out where in your own code you are being inefficient, specifically here:
the application runs so long as the phone is on and periodically takes information from many components and sensors on the phone.
If the device behaves fine when your code is not running, and the device does not behave fine when your code is running, then the problem lies in your code. Conversely, if the device does not behave fine even when your code is not running, then something else is afoot (device defect, firmware defect, rogue application, etc.), but it probably has nothing to do with StackOverflow.

Categories

Resources