Support Topics Documentation Slack YouTube Blog

MessageStatus in Async Call giving casting exception


(Muhammad Kamran Latif Raza) #1

Logcat of error


java.lang.ClassCastException: java.util.HashMap cannot be cast to com.backendless.services.messaging.MessageStatus


at com.<Package-name>.others.Helper$6$1.handleResponse(Helper.java:306)
at com.backendless.async.message.AsyncMessage$ResponseHandler.handle(AsyncMessage.java:64)
at com.backendless.async.message.AsyncMessage.handleCallback(AsyncMessage.java:41)
at android.os.Handler.dispatchMessage(Handler.java:98)
at com.backendless.core.AndroidCarrier$1.handleMessage(AndroidCarrier.java:37)

Here is code that was working just fine 2 days ago.

Backendless.Messaging
 .publish(
 ch,
 (Object) jsonResponceData
 .toString(),
 publishOptions,
 deliveryOptions,
new AsyncCallback<MessageStatus>() {
 @Override
 public void handleResponse(
 MessageStatus status) {
 progressDialog.cancel();
 }
 @Override
 public void handleFault(
 BackendlessFault fault) {
 progressDialog.cancel();
 showErrorDialog(
 context,
 fault.getMessage()
 + "\n"
 + fault.getDetail());
 }
 });


(Muhammad Kamran Latif Raza) #2
Tried with 
compile 'com.backendless:backendless:+' 



and this as well
compile 'com.backendless:backendless:3.0.20.1' 



also used jar file but still no luck…


(Muhammad Kamran Latif Raza) #3

While you guys are busy with other things, I was looking for an answer to my problem.

I found it very odd that when I included AdMob into my code, it gives me error above mentioned. When I removed it and error is gone as well. Working fine.

Please Do something about it.


(Muhammad Kamran Latif Raza) #4

I used AdMob Code into PushDemo and Same result. That weird exception came from that app too. Check the log

log.txt (1.58kB)


(Muhammad Kamran Latif Raza) #5

Just curious, I changed ads library to StartApp that same problem occurs. Ads work fine in both cases. (admob & startApp).
I even tried to give ads a new Handler runnable as well

Handler handler = new Handler(); 
 
Runnable runnable = new Runnable() { 
 @Override 
 public void run() { 
 // Get the Main relative layout of the entire activity 
 RelativeLayout mainLayout = (RelativeLayout) findViewById(R.id.content_inbox); 
 // Define StartApp Banner 
 Banner startAppBanner = new Banner(context); 
 RelativeLayout.LayoutParams bannerParameters = 
 new RelativeLayout.LayoutParams( 
 RelativeLayout.LayoutParams.WRAP_CONTENT, 
 RelativeLayout.LayoutParams.WRAP_CONTENT); 
 bannerParameters.addRule(RelativeLayout.CENTER_HORIZONTAL); 
 bannerParameters.addRule(RelativeLayout.ALIGN_PARENT_TOP); 
 // Add to main Layout 
 mainLayout.addView(startAppBanner, bannerParameters); 
 
 } 
}; 
handler.post(runnable); 



But no luck. I think this is as far as my knowledge goes. I can’t think of something else except waiting for a good answer from support.
Push messages receive correctly, but cannot send them.