Skip to content

Instantly share code, notes, and snippets.

@patrickhammond
Created February 25, 2016 00:47
Show Gist options
  • Save patrickhammond/99a087005fa70b257056 to your computer and use it in GitHub Desktop.
Save patrickhammond/99a087005fa70b257056 to your computer and use it in GitHub Desktop.
public class MainActivity extends ActionBarActivity {
private static final String QUANTITY = "quantity";
private int quantity = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState != null) {
quantity = savedInstanceState.getInt(QUANTITY);
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(QUANTITY, quantity);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment