Do I need Google Play Services for a Specific App - android

I have written an app that monitors accelerometer events for a few months. To minimize the battery usage the app only shows a black screen with the following services:
Accelerometer events
HTTP request services to send the data based on accelerometer events (I am using the Google Volley library, is this efficient from battery usage point of view?)
My question is can I disable Google Play Service for these events (and any other services using high battery power)? Is anyway to disable all notifications to minimize the battery usage?
Any other suggestion to minimize the battery usage is welcome.

There are few phones comes without google play services. I believe disabling is not possible. If you try, it may break the phone.

Sadly there is no way stop it completely. It will always restart if you try to stop it

Related

How do I use SpeechRecognizer in a PeriodicWorkRequest?

I'm trying to speech recognize every 15 minutes for this I'm using PeriodicWorkRequest but I get the error saying java.util.concurrent.ExecutionException: java.lang.RuntimeException: SpeechRecognizer should be used only from the application's main thread. How do I go about doing this? Is PeriodicWorkRequest the wrong approach?
If you are trying to use Android Framework API to do speech recognition, that functionality is only available with the foreground activity. Based on the error it appears that you are trying to listen from background which isn't possible starting with Android 9.
Background services has gotten stricter in recent versions of Android in order to improve battery life. Previously you might be able to use a Foreground Service to maintain your process, however with features like Doze Mode, Google is restricting the use cases even further. Even if you follow the recommendations for exemption and your app had directed the user manually exempt your app from 'battery saving mode' in Settings, device manufacturers have added their own battery saving features such that a site like: https://dontkillmyapp.com/ is need to understand the current state in Android.
Most likely, any background voice activation or listening app you may have seen was with older versions of Android, or custom software by device manufacturers.

Spotify Android SDK with Doze battery optimizations

When I use the Spotify Android SDK to play music and Doze kicks in, the music stops playing because the app loses network connectivity. Is there a way to solve this?
The only way I can think of is ask the user to whitelist the app using a ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS intent. But I read that a lot of developers get their app banned from the play store when doing that.
Running the Spotify instance in a foreground service fixes the problem. See https://developer.android.com/guide/topics/media/mediaplayer.html#foregroundserv

Android Geofencing and data communication doesn't not working because of battery optimalization

I'm working on a project that uses geofencing. When user enters the geofence area a webservice call occour. After 3 days if the user doesn't start the application the system optimizes it by disable geofencing and/or network communication.
I've tried android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission that worked fine, but Google rejected the new version of the app for violating policy. Can you give me some advice what should I do to avoid battery optimalization (or to Google accept the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS).
Thanks

How does doze mode affect background/foreground services, with/without partial/full wakelocks?

This is a simple question, seeing that there is a huge post about this on G+ (here), and lack of information on official docs (here ):
What happens to the app's services when the device goes to "doze" mode?
What does it do to background/foreground services (bound/unbound, started/not-started), with/without partial/full wakelocks?
What would you do, for example, in order to create a service that plays an audio stream while the device's screen is turned off? What if the audio stream is not from a local file, but from the network?
Seeing that there was a claim by Google developer:
Apps that have been running foreground services (with the associated
notification) are not restricted by doze.
-yet a lot of discussion after that, claiming this is not entirely true, I think it's quite confusing to know what special background-operations apps should do.
Processes which have a current running foreground service are supposed to be unaffected by Doze. Bound/unbound, started/not-started, and wakelocks do not affect this whitelisting process.
However, there is an issue on Android M devices where foreground services are not properly whitelisted when the foreground service is the in the same process as the top activity and improperly dozed.
The fix is available on AOSP and will be included in builds of Android N. It would be up to OEMs to integrate that patch into any Android M builds they produce.

Android - Alarm at location

Theoretic question.
In my app I need to create alarm at location functionality.
So user can pick location, set alarm and any time while She/He
will get closer to location alarm will trigger.
I know that I have to create Service to listen the current
location. It is obvious that I can't use GPS.
Any ideas how to figure it out if device is close to location?
I know that I still have Network location, which probably I will
use, but I afraid of that this will consume to much energy.
If there is any internal android system service which provide such
data? That I can just setup receiver.
Any ideas are welcome ;)
I suggest building on Google Play Services in order to get the product working quickly. Of course if you need to target non-Google phones, then program this manually, but only if you have to.
Play offers Geofencing apis - here are the docs:
Creating and Monitoring Geofences
PROS:
Google is constantly updating the Play sdk to optimise the features.
quick to get it working
battery efficiency
CONS:
it will not work on non-Google API devices, i.e. Kindle Fire
Upshot of all this:
if your app relies on Google Maps at all, then use the Play Geofencing.
I decided to use ProximityAlarm in Service.
Great example from this post:
Android GPS proximity alert not working

Categories

Resources