Update widget on Android O - android

My app does not receive ACTION_SCREEN_ON or ACTION_USER_PRESENT on Android O device after device remains idle for some time.
My app has widgets. I update those widgets with data from backend when the user unlocks the phone. This functionality has been working when I am targetting SDK 25.
Now I am compiling the app with target SDK 26. I converted the service that gets data for widgets to JobService. Everythings works fine when the user adds the widget to the home screen. Then if I kill the app and turn off the screen and say after 5 minutes if I unlock my phone, my app receives ACTION_SCREEN_ON and ACTION_USER_PRESENT intent I am able to start the service and update data on the widget. However, If I leave device idle for a couple of hours and then when I unlock the screen, the application does not receive ACTION_SCREEN_ON and ACTION_USER_PRESENT intent.
Is this due to Android O limitations on implicit intents. If so how have you solved the problem?
If not then what method has worked for you?

Related

No services are working on One plus 5T OS android OS 9.0

I have created the application for getting the Users latlong and send them to the server. So, now we have created the Foreground services for the getting the USER's location and is working fine in the All the other devices including the Android OS 9.0.
But in the specific OnePlus 5T Android 9.0 device the foreground service stops working when the device is locked and Service is also terminated after one hour, also even after we have disabled the deep cleaning option there.
Please let us know if there is something with the Device specific config that we need to change for working foreground service continuously.
Reason behind that- Alarm manager is not calling on time even if you are using setAndAllowWhileIdle() or setExactAndAllowWhileIdle() it won't work and pending intent also get destroy, Only High priorities task get executed in system like FCM push notification.
So the solution I found is :- implement push notification in your android application and send data message through push notification and start service from
public void onMessageReceived(RemoteMessage remoteMessage) {
//start your service from this method
}
note :- Check your Force Stop button of that application is enable or disable
if its disabled that means system complete killed your application
Android doze-standby mode and idle mode

If android application is installed in mobile but never launched .is BootCompletedReciever called?

If android application is installed in mobile but never launched and considered i have implemented boot completed receiver for this application.Now i am going to reboot the device .here boot completed receiver will call or what will happens?
No You have to launch the app once to register receiver with the device. Without launching the application Device will not detect your broadcast receiver.
Set the RECEIVE_BOOT_COMPLETED permission in your application's manifest. This allows your app to receive the ACTION_BOOT_COMPLETED that is broadcast after the system finishes booting (this only works if the app has already been launched by the user at least once)
The documentation clearly states that it works only if the app has been launched at least once. So the answer of your question is NO, it wont be called.

Broadcast and service not working after clearing my app from recent app manager

I am developing app like true caller. services and broadcasts working as per expectation in emulator but not working so well in my real device after clearing app from recent app.
I am using Redmi 1's. to test in real device.
when i clear app from recent app manager it not receive broadcast receiver and stop all services.
in the same device when i install truecaller it's working fine. when i check in
Setting->apps->running app there is true caller 1 process and 1 service always running in my device even after i clear it from recent app manager.
how to achieve this types of functionality which always receives broadcast even after app cleared from recent app manager?

How to keep listening the S Pen detachment after the app gets closed from the Recent Apps list?

The goal is simple: to start an app when S Pen is detached. It is clear that it should be a service running even when the app is not running. This answer provides a good example of how to create a service to listen S Pen detachment by registering a receiver with BOOT_COMPLETED action. It does not matter whether you start your service from the app activity, or by registering a receiver - it works fine if you just "close" the app using Back button. But if you go to the list of recent apps and clear the app out of the list - the service stops and it does not work until you restart the device again. Does anyone have an idea how to keep listening the S Pen detachment even after the app was cleared out of the Recent Apps list?
Register a Broadcast Receiver for com.samsung.pen.INSERT as described in this answer: Bring your app to the front when S Pen detached in android note?

how does whatsapp service gets restarted even if i force stop app?

I am running whatsapp (we could call it appX from now on) in device A. I go to manage applications -> force close so appX gets closed and i no longer see appX as running services.
Now, after 5 minutes, I send a message from another device 's appX (device B) to device A appX (the one we killed it).
Here are the 2 scenarios i tested :
device A with android 2.1 : it never receives the message, therefore we could say that none of appX services got restarted. It ONLY receives the message if manually the user restarts the app.
device A with android 2.3.6 : for SOME magic reason, no matter how long it's been since appX got killed, as soon as we send the message from device B -> device A gets the message, therefore, appX's service gets restarted. Note : all the time that appX was closed and WITHOUT receiving any notification, i wasn't able to see any running services of appX in manage applications, so this means that this magic service gets restarted as soon as it receives a message/notification
I know it sounds weird, and lot of people will say this is impossible, but again, this has been tested on these 2 devices.
I am trying to accomplish this same behavior, so any help will be appreciated it.
I don't think it's some magic what happens here! It's just Android C2DM (see: https://developers.google.com/android/c2dm/), whereas the app has a registered Receiver for incoming Push Notifications and gets awaken by this message.
Android C2DM is/was available with Android 2.2, that's the reason why you can't see the same behaviour on your device with Android 2.1 up and running.
By the way: As you can see, C2DM is deprecated since June 26th, 2012. So instead of C2DM, one should use GCM (see: http://developer.android.com/guide/google/gcm/gs.html)
Useful Comment: GCM needs available internet connection. You can using any other broadcast receiver such as SMSReceiver for by passing this limitation.
Starting from Android 3.1 (API 12), if an application is force-stopped it will not restart until the user manually runs the app again.
This will happen even if the app contains a Service or an active BroadcastReceiver.
You can find the official documentation here.
i dont have idea about whatsApp service.
But it is possible that after force stop application, restart service of app.
i use START_STICKY service for my chatApp. i have to do same thing so i use START_STICKY service so when my app kill or force stop from setting, after few second my service get restart and i able to login to my xmpp server and get incoming message.
its nothing magical here appX uses push notifications via android GCM platform https://developer.android.com/google/gcm/index.html in GCM the app registers for a braodcast reciever and the broadcast receiver starts the service on getting the push notification.
Android GCM is dependent on google play services that are available on android 2.2 and beyond that therefore you didn't see the message on 2.1 device

Categories

Resources