简体   繁体   中英

How to prevent TransactionTooLarge exception while passing data between JobIntentService to activity via Broadcast receiver

After login Page, I am downloading data from server using JobIntentService and passing the data to activity via BroadcastReceiver. For smaller amount of data it works fine but when I am working on live data it is giving below exception:

Caused by: android.os.TransactionTooLargeException: data parcel size 1450704 bytes
        at android.os.BinderProxy.transactNative(Native Method)
        at android.os.BinderProxy.transact(Binder.java:1127)
        at android.app.IActivityManager$Stub$Proxy.broadcastIntent(IActivityManager.java:3893)
        at android.app.ContextImpl.sendBroadcast(ContextImpl.java:1009)
        at android.content.ContextWrapper.sendBroadcast(ContextWrapper.java:444) 

I passing data like this from service class : 
Intent intent = new Intent(ACTION_CHECK_DOWNLOADSTATUS);
intent.putExtra("response",response);
sendBroadcast(intent);


But it gives TransactionTooLargeException..
How to prevent this?

How do I pass large amount of Data ??

Pls suggest...

You cannot pass "large amount of data" in an Intent . If you have a "large amount of data" to pass then you need to use one of the following:

  • Store the data in SQLite database
  • Store the data in a file
  • Store the data in a public static variable so that it can be accessed by all classes in your application (isn't the best alternative, as there are issues around app restarts, but it is the simplest method)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM