简体   繁体   中英

Altering Bundle savedInstanceState

I want to create an app that acts as frontend to launch an emulator with preloaded game.

I have the emu source code, but I can't edit it. In the onCreate(Bundle savedInstanceState) method of the emulator's main activity there is this line:

if (savedInstanceState != null)
    currentGame = savedInstanceState.getString("currentGame");

Which seems the line that makes the emulator run the latest game if one is found when the activity is (re)created.

Is there a way to edit the savedInstanceState so that it contains the currentGame string?

when the activity is first created the savedInstanceState is null, and in subsequent calls it's not. To make sure that the savedInstanceState is not null, there is a method called onRestoreInstanceState() that you should override, and for sure it has the string you're looking for.

but i think that what you realy want is to send an intent to that activity with a Bundle already filled with that string. if it's not what you want please explain a little more what is your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM