1. Download our Official Android App: Forums for Android!

Apps How can I save a surface view drawing when going to a new activity view?

Discussion in 'Android Development' started by Akomada, Apr 9, 2016.

  1. Akomada

    Akomada Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    1
    Joined:
    Apr 8, 2016

    Apr 8, 2016
    1
    0
    5
    Male
    Basically, I have a gameView class, which extends Surfaceview, it has a surfaceCreated method, which runs a thread and draws stuff onto a canvas.

    This gameView gets loaded from a GameActivity, with setContentView(gameView).

    On the gameView, I have a touch event, so that when you touch the screen you get navigated to another activity xml layout. Basically, when you touch the canvas drawing another screen pops up.

    On this new, intermediate screen I have a button which when you click it, it takes you back to the gameView.

    My problem is that when it takes you back to the gameView, the canvas drawing has been reset, it seems that the surfaceCreated method is called each time with setContentView(gameView).

    So my question is how can I save the gameView, its state and its canvas drawing, so that when I navigate to another activity but come back and load the gameView again, the state will still be there, and it will redraw what it had?
     

    Advertisement

  2. LV426

    LV426 I say we take off and nuke this place from orbit
    Recognized Developer
    Rank:
     #12
    Points:
    1,988
    Posts:
    9,176
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    9,176
    13,681
    1,988
    Male
    Software developer
    South West of England

Share This Page

Loading...