So I have been using the getIntent method to send my original int value, set to 10, to a second class.
Intent webClick = new Intent(this, WebsearchIAP.class);
webClick.putExtra("cred", cred);
startActivity(webClick);
Then, I update the variable by subtracting 1 from it.
Intent get = getIntent();
int cred = get.getIntExtra("cred", 10);
public void buyClick(View view) {
sCredits.setText(cred - 1);
}
Then, I want to send it back to my MainActivity, by doing this.
public void backClick(View view) {
Intent close = new Intent(this, MainActivity.class);
close.putExtra("cred", cred);
startActivity(close);
}
Once back in my MainActivity, this is what I would like to do.
@Override
public void onResume() {
super.onResume();
Intent close = getIntent();
int cred = get.getIntExtra("cred", [VALUE OF CRED IN PREVIOUS ACTIVITY]);
}
My problem is the getIntent method requires the numerical value of "cred", which would be no big deal if I was using the method only once, but I want to use it every time this app resumes the main screen, hence the call to onResume. So, how do I set my app to take the value of "cred" in the previous activity, no matter what it may be, in one method?