Search code examples
ibm-cloudibm-mobilefirstibm-mobile-services

Android mobile first app stopped working after Bluemix moved to cflinuxfs2 stack


I have an android app based on the bluelist app for bluemix BMS service. it stopped working yesterday when the stack is moved to cflinuxfs2. Today I checked my ios app on the same bluemix service, it is working. so I looked into the exception on Android, it is from MFPush, looks like a context is null. see the attached image for the line of code where the NPE is thrown.enter image description here The stacktrace is: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Intent android.content.Context.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)' on a null object reference 12-10 16:00:31.240 14482-14482/com.ibm.bluelist E/AndroidRuntime: at com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPush.listen(MFPPush.java:232) 12-10 16:00:31.240 14482-14482/com.ibm.bluelist E/AndroidRuntime: at com.ibm.bluelist.GroupsActivity.onResume(GroupsActivity.java:250) 12-10 16:00:31.240 14482-14482/com.ibm.bluelist E/AndroidRuntime: at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1257) 12-10 16:00:31.240 14482-14482/com.ibm.bluelist E/AndroidRuntime: at android.app.Activity.performResume(Activity.java:6119)


Solution

  • Chances are the MFPPush SDK has not been initialized when you are attempting to call: push.listen(notificationListener)

    I suggest saving the push value: push = MFPPush.getInstance() Immediately after initialization or registration (whatever you feel is more appropriate) in the class.

    That way you will have the appropriate initialized push instance when attempting to listen to a notification listener.