I'm working on a minesweeper game on android studio.What I'm trying to do is to save the state of the game if the user closes the game while playing.I'm having trouble using parcelable
on a object that extends Button
Like this:
private final Tile[][] mData = new Tile[8][8]; //8x8 grid
public class Tile extends Button implements Parcelable
{
private boolean isMine;
private boolean isFlag;
private boolean isCovered;
private int noSurroundingMines;
I know i need to use onSaveInstanceState
and use Parcelable
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
savedInstanceState.putParcelable("test", (Parcelable) mData); <--Error
}
*Error:Inconvertible types;Cannot Cast GameActivity.Tiles to android.Parcelable
I also know that you can't save 2d array and i'm aware of the work around. I realy want to find out how to save an object that extends button