This app demonstrates a non-deprecated way of keeping the first Etch A Sketch’s drawing intact when the orientation changes.
The
Path
lives inside a
RetainedFragment
in
EtchView.java
.RetainedFragment
holds the
Path
and provides a getter,
and does very little else.
But the
RetainedFragment
is potentially capable of outliving the
Activity
that created it.
In fact, it will outlive the
Activity
,
thanks to the call to
setRetainInstance
,
and will be read by the next instantiation of the
Activity
.
The
FragmentManager
keeps the fragment alive in between incarnations of the
Activity
.
EtchActivity.java
EtchView.java
main.xml
:
unused.AndroidManifest.xml
:
untouched.