我正在尝试通过Intent.putExtras
这样将数据从一个活动传递到另一个活动:
private ArrayList<HashMap<String, String>> mGroups = new ArrayList<HashMap<String, String>>();
private ArrayList<HashMap<String, String>> mUsers = new ArrayList<HashMap<String, String>>();
...
Bundle data = new Bundle();
data.putInt("mode", mode);
data.putSerializable("groups", (Serializable) mGroups);
data.putSerializable("users", (Serializable) mUsers);
data.putInt("current_class", mCurrentClassId);
data.putInt("current_user", mCurrentUserId);
Intent intent = new Intent(ctx, ChildActivity.class);
intent.putExtras(data);
ctx.startActivityForResult(intent, 0);
这里mUsers
是包含用户数据的HashMap<String,String>
列表,包括Base64编码的照片,此列表中字符串大小的总和约为500Kb
呼叫startActivityForResult
时黑屏挂了几分钟,然后出现ANR错误。完全不调用子活动的onCreate
。
如果我不向mUsers中添加大字符串(没有Base64编码的照片),则工作正常。
请帮助。
如果这两项活动都是您的,请使用体面的数据模型。 Android不鼓励设计精良的应用程序。或换种说法,它允许快速开发应用程序,并且不会促进很多好的软件应用程序原理。
仅是对Snicolas的回答: