Google Cloud Messaging - onRegistered not called on Android 9.0 Pie - android

Before I begin, I understand that GCM is depreciated, but due to time and resource constraints on this ticket, I don't think migrating to FCM is feasible at this juncture. I didn't write the app (the contractor who did it is long-gone by now), I just need to fix it if possible. If it's not possible without doing a migration, I'd like to just relay that information onwards instead of continuing to bash my head against this any longer.
My question, in short, is this: Was there anything introduced in Android 9.0 (API 28) that would preclude the GCM registration process from working? The app works fine on all preceding versions of Android, but not Pie.
More info: When the app starts on a fresh 9.0 device, a call to GCMRegistrar.getRegistrationId() is made. It returns a blank string, as expected. Intent filters are created, receiver is registered, etc. Finally, a call to GCMRegistrar.register() is made. On every other version of Android, I get a response with a registration token that gets fielded in the onRegistered method in the GCMIntentService class. For some reason, this callback method is never called on devices running Pie.
What I've tried: Already updated play-services-gcm to v16.0.0. Min sdk is 14. Target is 28. Ran some debug broadcasts that target my receiver, it still functions. Still can't find a good reason why onRegistered suddenly isn't being called on this version of Android.
I'm more or less unconcerned about the code and/or manifest because, again, it has been chugging along fine on hundreds of devices for many years now. Did Google just cut life support for GCM registration at the OS level with Pie or something? If not, are there Pie-specific changes that need to be made to get it to work? Looking at Google's documentation, their solution seems to be "migrate to FCM", but as I mentioned before, that's not an option at the moment.

As I mentioned in my comment, the rollout isn't supposed to come to full fruition until April of 2019. With that said, it's hard to say without code, but depending on your implementation and that you mentioned the GCMIntentService it could have something to do with the changes to how background Services are allowed to run in Android Pie. See this post for more details.
Check your logcat to see if you get any errors when trying to start the Service during the registration process.

Related

Issue in SM-G950F(Samsung s8) for running OneoffTask

I am facing an issue, where my app users cannot get past a point.
When the user tries to login, it gets logged in, but after that I hit an API with "OneoffTask" using this code :
OneoffTask task = new OneoffTask.Builder()
.setService(SyncService.class)
.setTag(TaskConstants.UPLOAD_STREAK)
.setExecutionWindow(0L, 200)
.setRequiredNetwork(Task.NETWORK_STATE_CONNECTED)
.setPersisted(true)
.setUpdateCurrent(true)
.build();
GcmNetworkManager mGcmNetworkManager = GcmNetworkManager.getInstance(MainApplication.getContext());
mGcmNetworkManager.schedule(task);
This code is executed, but the scheduled task does not execute. samsung s8 model : SM-G950F. It is working on all other devices. Why is this issue, I am also not getting an error. It is just stuck there.
I'm not able to comment, so I have made some assumptions regarding the issue you are facing and hopefully have this right. Please let me know if that is not the case.
The Samsung S8 is probably upgraded to Android 8.0 (Oreo), right?
In Oreo there are limitations that you need to handle in a different manner.
Android 8.0 places limitations on what apps can do while users aren't directly interacting with them. Apps are restricted in two ways "Background Service Limitations" and "Broadcast Limitations", reference: https://developer.android.com/about/versions/oreo/background#overview
Also the GcmNetworkManager require that the user have "play services" installed, you have to ensure to check that. GCM is also soon deprecated so look for other solutions, replaced by FCM for instance: https://developers.google.com/cloud-messaging/android/client (see also requirements to ensure the S8 meets them).
To ensure that GcmNetworkManager scheduler works as espected you need to combine it with a JobScheduler. Best reference I found is this: https://github.com/yigit/android-priority-jobqueue/wiki/Integration-with-JobScheduler-and-GcmNetworkManager
My experience with JobScheduler is that it is working great on all newer devices I have tested (Android 6.0 --> 8.0) so hopefully you don't need so much "Oreo-logic".
Please let me know if that got you in the right direction :)

NotificationListenerService is not getting bound to SystemUI on Android 8 (Oreo)

Based on my testing, it appears that the NotificationListenerService(NLS) in my android app is not getting bound to the system on Android 8 (Oreo). I am targeting my app for SDK version 26 to make it compatible with the new OS.
Prior to Android N, the NLS service was bound to SystemUI forever (Ref: Google I/O 2016). Starting from Android N, two new methods were introduced in NLS service: requestRebind(ComponentName) and requestUnbind().
In Android Oreo, there are new Background Execution Limits that apply to services. However, it does not apply for certain services, such as a "Notification listener that another app binds to". This is my use case, as I am using an NLS service that is supposed to be bound to the SystemUI.
However, as I observed, this service is never getting bound to SystemUI. Additionally, even if I explicitly call requestRebind(ComponentName), the service is never getting bound and hence it is non-functional because this means I am unable to listen to notifications.
How do I fix this problem in Android Oreo?
Oh boy, this is silly! The issue was resolved by a reboot. I suppose Android was misbehaving on my phone and simply refused to work the right way. Rebooting the phone and trying again made the service work the way it is supposed to!
I'll leave this question up as a reminder to all that sometimes the simplest and most cliched fix (i.e. "Did you try turning it off and on again?") is the right answer!
Good grief!

Google CloudPrint printing infinite copies (Android)

I have been using Google CloudPrint since December, and suddenly (sometimes, mostly when the networks is slow) when printing, it keeps printing.
I am using this configuration: Android Phone, my App creates a print job with ticket via Google CloudPrint, the android notification center displays the print job "Printing" (as in sending...), the Google CloudPrint receives the task, and prints it with the printer associated, then, normally, it removes the print job from the notification center. and thats all.
Now, it stays in the notification center... for ever, even if you cancel, it already sent a lot of print jobs (they are slow to appear on the GoogleCloud panel).
Is there a bug with Google CloudPrint or is a problem with my (probably outdated now) code?
I know is Beta, and that, but i neither find documentation, known bugs, or anything at all.
If you can guide me in solving this problem...
(This is the code i use to send the intent)
PrintHelper photoPrinter = new PrintHelper(Context);
photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT);
photoPrinter.printBitmap("print job", bitmap);
I had the same issue on a Samsung Galaxy Tab 4. I uninstalled Cloud Print and then reinstalled. Fixed the issue.

Voice recognition not working as a service when Google Search version > 2.2.10.573038

Some friends and I have been working in an app that requires to have a service running listening for voice commands. We have successfully implemented the listener. However, after we started having problems because the operating system killed the service after a while (I suppose to reclaim some resources). We (apparently) fixed this problem by making the service a foreground process (calling startForeground).
We have been testing the app in a range of devices and we found out that the app was still being killed by the OS in some devices. Having a close look at this issue we found out that the devices where the app is being killed have Google Search version greater or equal to 2.3... (for instance 2.4.10.626027) If we uninstall the updates and downgrade to version 2.2.10.573038 then it works like a charm.
By the way, I have mentioned Google Search here because when we start the voice listener, a package named com.google.android.googlequicksearchbox is started.
Does anyone have an idea of why this might be? or what main differences exist between the versions 2.2.10.573038 (and older) and those after? Of course the solution would be to downgrade the version but we would like it to be compatible with the newer versions too...

C2DM handle registration properly

I want to use C2DM in my android application. I am using code schemas shown in official tutorials. Everything seems to work fine, but I have problem with handling registration properly.
There are 2 methods in C2DMMessaging class which I have to use: firstly register() and next getRegistrationID(). If I use them sequentially, I get null form the getRegistrationID(). The problem is registration is asynchronous. In my application in the beginning I need to know the regidtrationId, I can start the rest of the app only after I get it.
I tried to do some synchronization using monitors (i.e. wait() in register method and notify() in C2DMReceiver.onRegistered()), but it didn't work (the code of onRegistered() hasn't been reached, after calling wait() in register()).
In other words what I need is making registration synchronous, so I could continue, only after I get registrationId. What is the right way to do it?
Make sure you are following below guidelines:
To develop and test on the Android Emulator, you need to download the Android 2.2 version of the Google APIs Add-On into your SDK.
Make sure you set android:minSdkVersion="8" in the manifest.
Make sure you have at least one Google account synced on your emulator or device.

Categories

Resources