I'm working on portrait and landscape view of an Android Apps.
As the data are lost when we change orientations I thought to store the data in a bundle by overriding the method onSavedInstanceState
and restoring the data from onRestoreInstanceState
.
It is working fine but I want to store the background color of the app in the bundle since its a random color and I don't know what is the background color.
Can we do that or is there any other way around that can solve this problem?
You can pass the color as an integer. Something similar to this example:
Random rnd = new Random();
int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
view.setBackgroundColor(color);