开发者

Adding Intent putextra method taking time

I am adding some large serializable object (say data) to the Intent's putextra() method:

Intent intent = new Intent(currentScreen, newScreen.getClass());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Bundle bundle = new Bundle();
intent.putExtra("DATA", data);
intent.putExtras(bundle);
currentScreen开发者_开发知识库.startActivity(intent);

newScreen taking much time to start and display.

Please let me know how to overcome the issue.

Thanks Android_IT


Don't just assume the large extra data is causing your app to be slow. Profile it with Traceview and make sure. If it does indeed turn out to be the problem, my only suggestion is to store it in a static member before starting the new activity and then retrieve it from there. This way it will not be copied around and serialized/deserialized.


If NewScreen take too much time you are probably doing some time consuming task in the onCreate method of NewScreen.See what is happening there by printing some log to see whether onCreate of newScreen fired immediately or not

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜