Greatings!
We are developing an android app with Xamarin that has to meet the following restrictions:
wifi yes, but no internet connection
no FCM/google play services (app should also work in China)
push messages from a Manager-SW (uses rabbitmq) need to arrive quickly after being send (< 1min) AND also when the device is in doze mode
no pulling mechanism
At the moment we are having a wifilock and a wakelock. The battery optimization for this app is turned off. This way messages always arrive even when the device goes to doze mode.. with some exceptions.
There are devices like the HUAWEI P20 that have their own battery save solution (App launch) --> app is not running although we have all the stuff above
Also this solution is not ideal considering battery usage.
I have looked into alternatvies like Pushy, but for me it seems they have problems with doze mode too.
Do you know any alternatives to FCM?
Is there any easy way to go around the Huawei stuff without the user having to change the settings manually?
Many thanks to all of you in advance!
Related
I'm building an app that has two background/foreground services:
Sync with API on FCM data notification - high priority
Physical activity monitoring using Activity Transition API
This app is also ignoring battery optimization(on the exemption list).
If app is terminated and devices put to sleep, these services function properly for about 24 hours. After then they both just stop.
Devices has no battery saver mode enabled, it's unpluged from charging and the battery is at 90%. The device is Samsung with Android 11. App is not on the sleep/deepsleep list.
I can't get my head around why these services just drop out after those ~24 hours. Based on Android documentation, app with ignored battery optimization shouldn't Doze. And FCM message with high priority should wake the app from Standby. When this happens nothing really helps, I have tried manually disabling standby using adb and put the device on charger. The only thing that helps is relaunching the app.
Any help would be greatly appriciated.
My Android app does not receive FCM push messages immediately, if the phone is on standby and not currently charging. I think I really set everything I could in the phone settings regarding energy saving... Is there something I can do in the app itself?
It works on other manufacturers but on our Huawei it doesn't...
These phones tend to kill all background app. I mean no sticly service and broadcast receivers as well. Try whitelisting your app from battery settings. It will prevent your app from getting killed by system
I'm working on legacy VOIP application on Android.
It doesn't use Google Cloud Messaging technology right now, but just keeping its own TCP connection forever.
Recently Google has introduced its Android M preview release with Doze mode
So the question: is there any workaround how the app can receive incoming calls/messages in Doze mode without redesigning the whole system to use GCM?
You may use ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS to ask the user permission to be ignored by battery optimization. However, double check Optimizing for Doze and App Standby, it seems to be allowed only for enterprise VoIP/IM (see questions #33114063 and #31154128)
No, GCM seems to be the only way. See a great analysis of the problems with doze mode including network and GCM here:
https://commonsware.com/blog/2015/06/03/random-musing-m-developer-preview-ugly-part-one.html
It's working well on most Android devices.
Other device's screen gets locked after 1 minutes BLE device gets disconnected,if device without charger.
Thanks for any suggestions!
this might come from the Keep Wi-Fi on during sleep option (which might affect all radios) - as it seems this only exists in 8.0 but not in 8.1 (at least on the Pixel 2 XL, according to this article).
You might be having this problem because your app is not properly configured to handle Doze mode.
While there do not seem to be any restrictions on using BLE itself, doze mode might be messing with the control mechanism for your bluetooth connection (ex: a background service).
To see if this is the issue, you can whitelist your app manually via Settings > Battery > Battery Optimization and disabling optimization for your app.
Furthermore, as of Android 8.0, there are restrictions on background services when your app is not in the foreground. So, you may need to create a foreground service to handle the connection.
There are 3 states an Android phone can be in: Awake, Asleep and Off. See: Android: Sleep stages/levels on an Android device?
In sleep mode screen goes off, CPU shuts down along with Wi-Fi and GPS radios. See: http://developer.android.com/reference/android/os/PowerManager.html and Android Sleep/Standby Mode
But GSM or CDMA radio still works and the device can receive incoming calls, SMSes, and IP packets. Also, Google introduced new Google Cloud Messaging service that sends data to devices and can, as I understood, wake the device if necessary. See: http://developer.android.com/guide/google/gcm/index.html
So, my question is: can application on Android device be updated via Google Play if the device is in sleep mode? I mean is Google Play allowed to receive some kind of messages from the cloud, wake the device and update applications? I assume that the application is allowed to be updated automatically and can be updated through mobile network (3G/4G).
Thank you.
UPDATE: I did some research and it happens that Nippey's answer and comments are correct. I did not see any updates to wake my device but as soon as the device is awake updating mechanism starts to work normally. So, theoretically, Google Play Store can start updating your applications right after the device wake up.
The device is able to process push-messages while in sleep mode.
As soon as you trigger an update via the play.google.com, this will issue a push request, which, as a consequence will wake up your device. The update will be installed immediately.
So, it doesn't work in sleep mode, but if the device gets a trigger to wake up, it will do what has to be done.