livefront / bridge

An Android library for avoiding TransactionTooLargeException during state saving and restoration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bridge always need android state library to support with

AparnaKS opened this issue · comments

I am not using any android state library like icepick as saved state handler. But was directly keeping data to bundle using putParcelable, putByteArray etc. In this case how to use bridge library. I have integrated your library and for test purpose added data to bundle (like savedInstanceState.putByteArray("bytes", new byte[1000 * 1000]);) and have used Bridge to save my bundle eg Bridge.saveInstanceState(this, savedInstanceState);

When i checked the log i am still getting TransactionTooLargeException

Adding to the above, my writetodisk method is not executing as the bundle is null. Please suggest

Bundle bundle = new Bundle();
mSavedStateHandler.saveInstanceState(target, bundle);
if (bundle.isEmpty()) {
// Don't bother saving empty bundles
return;
}

Hi @AparnaKS . So this question was asked before here : #14 . There's a suggestion there for how to do this without a library like Icepick, but in the end your best option is just use something like Icepick.

The key idea here is that Bridge is constructed in a way such that given an object, your SavedStateHandler is responsible for adding data to the Bundle. It simply does not support directly adding data to the Bundle in the way you are suggesting. As suggested in #14 (comment) , using a new interface could allow you to manually add data, but still not quite in the way you are trying to do. You can refer to the sample app for correct usage.

Thanks for the quick response. It worked with custom StateManager interface. Thank you so much @byencho

No problem, @AparnaKS! Glad to help.