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

Unable to get Status of Check boxes as a child element of ListView Item
Autocomplete dropdown item text color in Theme.Holo.Light issue
Issues about Alarm Manager in Android
OpenGL ES 1.0 strange behavior for textures with gradients
Android login page throwing NullPointerException
Customs for submitting changes to an open source project? [closed]
Javah cannot find khronos.opengles.GL10
GridView items: set relative sizes
How can I generate a String Array for a ListView using conditionals to determine if the String elements should be on the List?
Getting data from Listview with BaseAdapter
Android How to implement services for time delayed actions?
Android InApp Billing gives RESULT_ERROR most of the time
Does Android 2.x support QVGA resolution?
Where is my database file in SQLite
How can i save Text to Speech file as .wav/.mp3 format in Arabic language in External Storage?
Getting a char array from the user without using a String

Categories

HOME
eclipse
scikit-learn
string
forms
amp-html
character-encoding
graphics
pyqt4
maxscript
webix
categorical-data
mel
java.util.logging
mautic
datastage
pybossa
renjin
gruntfile
esoteric-languages
mathprog
feathersjs
boost-icl
google-maps-autocomplete
ag
googlebot
backpack-for-laravel
easeljs
roundup
gpio
amazon-quicksight
jaws
carrierwave
calculation
autodesk-designautomation
recurring-events
sammy.js
hunspell
sql-delete
numpy-broadcasting
openerp-7
parse-tree
nohup
amazon-ses
p4merge
ogc
azure-arm
tinymce-3
reindex
context-switch
appdomain
git-flow
css-transforms
reshape
d3-force-directed
stax
ziparchive
microstation
expectations
refinerycms
cfchart
php-socket
createprocess
exim4
ascii-art
boomerang
iokit
binomial-theorem
lasso
bufferedinputstream
uncaught-typeerror
functional-java
radiant
twitter-bootstrap-rails
ecslidingviewcontroller
ice-cube
script#
nevron
scmmanager
mysql-error-2013
qi4j
window-decoration
entity-attribute-value
user-tracking
promotion-code
clrstoredprocedure
zend-rest
cfwindow
wcf-instancing
wysiwym
java1.4

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