android


Crash on passing large sets of data through intents - is there a size limit on the extras bundle?


I just started a new job and am working on an app that requires passing large data sets around the application. Currently the app uses persistent storage and is constantly querying a SQL database to fetch and display these large data sets to the user. Because of all of these expensive operations the app has become almost unusable (too many loading spinners for operations that take too long). My solution is to load the data when the main activity is launched and then pass it as needed to any new activities.
I implemented the first stage of this change with one data set. However, when I tried to pass the ArrayList with all this data in the intent's extras bundle I got the following error:
04-27 06:42:32.022: E/AndroidRuntime(14180): FATAL EXCEPTION: main
04-27 06:42:32.022: E/AndroidRuntime(14180): Process: com.myprocess, PID: 14180
04-27 06:42:32.022: E/AndroidRuntime(14180): java.lang.SecurityException: Unable to find app for caller android.app.ApplicationThreadProxy#42b32678 (pid=14180) when publishing content providers
04-27 06:42:32.022: E/AndroidRuntime(14180): at android.os.Parcel.readException(Parcel.java:1472)
04-27 06:42:32.022: E/AndroidRuntime(14180): at android.os.Parcel.readException(Parcel.java:1426)
04-27 06:42:32.022: E/AndroidRuntime(14180): at android.app.ActivityManagerProxy.publishContentProviders(ActivityManagerNative.java:2977)
04-27 06:42:32.022: E/AndroidRuntime(14180): at android.app.ActivityThread.installContentProviders(ActivityThread.java:4591)
04-27 06:42:32.022: E/AndroidRuntime(14180): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522)
04-27 06:42:32.022: E/AndroidRuntime(14180): at android.app.ActivityThread.access$1500(ActivityThread.java:151)
04-27 06:42:32.022: E/AndroidRuntime(14180): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
04-27 06:42:32.022: E/AndroidRuntime(14180): at android.os.Handler.dispatchMessage(Handler.java:110)
04-27 06:42:32.022: E/AndroidRuntime(14180): at android.os.Looper.loop(Looper.java:193)
04-27 06:42:32.022: E/AndroidRuntime(14180): at android.app.ActivityThread.main(ActivityThread.java:5292)
04-27 06:42:32.022: E/AndroidRuntime(14180): at java.lang.reflect.Method.invokeNative(Native Method)
04-27 06:42:32.022: E/AndroidRuntime(14180): at java.lang.reflect.Method.invoke(Method.java:515)
04-27 06:42:32.022: E/AndroidRuntime(14180): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
04-27 06:42:32.022: E/AndroidRuntime(14180): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
04-27 06:42:32.022: E/AndroidRuntime(14180): at dalvik.system.NativeStart.main(Native Method)
Which, based on this stackoverflow post: Using Crop intent Getting java.lang.SecurityException: Unable to find app for caller android.app.ApplicationThreadProxy#4266ae80 as well as testing with smaller data-sets I figured out was (almost certainly) being caused by sending too much data via the intent extras bundle.
I have two questions.
First, does my assessment sound correct? I haven't been able to find anything from the last four years that explicitly states that the extras bundle has a size limit (there's lots from 2012 and before though).
Assuming I'm correct, I'm planning on using a singleton to store data sets that are too big to be passed as an intent, and then implementing the necessary checks to ensure that it works with the activity life cycle (re-load the from the database if the activity is destroyed and I loose the data). Any other suggestions? I know this isn't exactly best practice but I can't think of a better way to do it.
I should also mention that because of the usability requirements for the app loading the data incrementally isn't an option.
Yes there is a limit, but it's not well documented how large or small it is.
See: Max size of string data that can be passed in intents
Some say you shouldn't try to pass anything larger than 90kb into the Intent extras. So the limit seems to be quite tight.
Your options:
Store the data in any easy to read temporary file and pass a file pointer to that file around.
Store the data in the Application instance of your app, not as a singleton but something accessible through (MyAppInstance) context.getApplicationContext().
Example of the last option:
Note: you might want to synchronize access to the data.
public class MyAppInstance extends Application {
private Object data = null;
public void setMyData(Object data){
this.data = data;
}
public Object getMyData(){
return data;
}
}
MyAppInstance app = (MyAppInstance) context.getApplicationContext();
app.setMyData(whatever);
whatever = app.getMyData();

Related Links

Complex RealmObject: RealmObject with other RealmObject inside
getResource returns boolean instead String[]
Android: Container XML Layout wrap weight and fill height
Busy Indicator in react native
Facebook Analytics In-app notifications not showing push opens
How to adjust the volume of two media players simultaneously?
2 Views side by side with the same height
How to keep http requests pending until restoration of internet connectivity in Android Apps?
Actionbar ShowAsAction always not work with spinner dropdown
Application class does not run when app start?
Trouble adding Logout Button to Tab Fragment Class?
How to disable certain dates in android in datetime picker
Realm Error Encrypted interprocess sharing is currently unsupported
Is it possible to publish the same app with different package names?
Signed Build with ShrinkResources - Notification Icon not visible
Reading RAW DNG files in android

Categories

HOME
android
phantom-dsl
eclipse
developer-tools
dns
amp-html
object
ms-access-2016
pdfbox
access
seo
rom
nuget-package
missing-data
opengl-3
teechart
rcloud
sendgrid-api-v3
jquery-ui-sortable
cmdb
selenium-ide
android-intent
alpacajs
google-content-api
apache2.4
solrcloud
windows-xp
googlebot
href
named-entity-recognition
visual-studio-extensions
beta
onload
opentk
openmdao
powershell-ise
utorrent
fstream
classcastexception
getlasterror
swagger-php
magento-1.9.2.4
recurrent-neural-network
escpos
subclipse
xmldocument
berkeley-db-je
x++
builder
dbcontext
remedy
arq
ngmaterial
jqchart
dt
django-1.10
redistributable
pacemaker
model-associations
jclouds
piracy-prevention
sapi
themoviedb-api
opserver
binomial-theorem
rpart
baasbox
mirror
snoop
kubuntu
fits
cross-join
teaspoon
machine-instruction
wcm
insight.database
scriptaculous
artemis
ie8-compatibility-mode
cocoalibspotify-2.0
poker
composite-component
jquery-blockui
os.system
jsr286
saxparseexception
clrstoredprocedure
cloudfiles
metaweblog
perl5.12
dsoframer
contentpresenter

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App