Problem
I'm making an app that can detect if current place is a particular place and play the sound if I'm locating in a particular place. So, I'm going to detect the place using wifi names(ssid).
Thus, I want to get ssid list when the app is running on background service. Also, it should always get ssid list because it plays sound when user reached the place.
Question
So my question is, How to always get ssid list and detect the place on background?
First, you should using a service to run a scan task, because of background limitation, my suggestion is foreground service, refer foreground-services
Second, about wifi scan feature, on Android, we can get a list of Wi-Fi access points that are visible from the device, but have few limitations apply to the frequency of scan, each background app (All background apps combined for android 9 and higher) can scan one time in a 30-minute period , and 2-minute period for foreground app.
please refer : wifi-scan-throttling
Related
I want to make and app with widget to present some data,and i want to be sure it will not become a battery drain source and add all the checks i have to,so there is no problem.
So android documentation actually says that ACTION_APPWIDGET_UPDATE may be sent in response to a new instance for this AppWidget provider having been instantiated, the requested update interval having lapsed, or the system booting.
But i came into this bizarre answer here
Android widget update called twice after device boot
that suggest that the home screen can actually update your widget n times at will.Seems bizarre,and i cant find something similar,do i really have no control over this?
As in the previous answer you found, there is no way to limit how many times the home screen might update the widget - it is responsibility of the homescreen and you cannot control this.
You could add a limit in your update implementation instead. For example, record the time the checks are made. If the widget update is requested again too soon after the last one, ignore it until the required amount of time passes.
I was just wondering if it was possible to force a scan for NFC tags on Android and how to do it. I want to know if I can call something like nfc.scan() and have it return the tag info if there is any tag detected. I am kinda new to this Android thing and so far I have only seen it done with intents.
No, Android does not allow you to trigger a scan for NFC tags/devices in range.
In fact, Android continuously polls1 for tags while the screen is on (and unlocked) and there is no currently detected tag. Thus, you can register your app to be informed when a new tag is detected -> this is done through intents.
1) Most Android devices employ some energy saving mode that prevents the device from continuously polling for all kinds of tags. Instead, these devices detect tags by sending a short impulse and measuring detuning effects from inductive coupling.
I'm learning about android development. Let's say I want to be able to listen to spotify music in the background, while simultaneously listening to a spoken word podcast thru some other podcast app. Ive tried creating a Soundbuilder object and changed the maxStreams to 2 when I hit a togglebutton. However, when I run the app it makes no difference. Either spotify has the focus or the podcast app has focus.
Should I be utilizing the AudioManager class instead? To be able to eventually controll the volume of each stream independently? Also, would the phone have to be root to be able to change the maxStreams to 2?
I think You should check this example: MixingAudioInputStream.java
It's example taken from here
Check these out and try mixing both streams into single stream by Yourself - as trying to code new things is best way to learn.
I was wondering if there is a way for me to detect if the users device is being "obstructed" by a building or roof of some sort. Im developing a very precise location based app and its KEY that my users get alerted if something is wrong with there GPS or something is getting in the way. Physical object.
EDIT: The app ive created strictly takes snapshots too its not something thats constantly going. Just a quick snapshot.
Not directly. You can try calling LocationManager.getGpsStatus and iterating over the list of satelites every so often and looking for a jump in signal to noise ratio since the last reading. Getting a working algorithm is going to take a good amount of work and testing on a variety of devices with different GPS chips.
I'm sure most of you have used an android phone before and taken a picture. Whenever the user changes the mobile phone's position and holds it steady, the camera focusses automatically. I'm having a hard time replicating this in my app. The autofocus() method is being called only once when the application is being launched. I have been searching for a solution these past 3 days and while reading the google documentation I stumbled upon the sensor method calls (such as when the user tilts the mobile forwards or backwards). I could use this API to achieve what I need but it sounds too dirty and too complicated. I'm sure there's another way around it.
All examples on the internet which I have found only focus when the user presses the screen or a button. I have also gone through several questions on SO to hopefully find what I am looking for but I was unsuccessful. I have seen this question and that String is not compatible with my phone. For some reason the only focussing modes which I can use is fixed and auto.
I was hoping someone here would shed some light on the subject because I am at a loss.
Thankyou very much for your time.
Since API 14 you can set this parameter
http://developer.android.com/reference/android/hardware/Camera.Parameters.html#FOCUS_MODE_CONTINUOUS_PICTURE
Yes, camera.autoFocus(callback) is a one-time function. You will need to call it in a loop to have it autofocus continuously. Preferably you would have a motion detection via accelerometer or compass to detect when camera is moved.