trying to use putExtra and getExtra with Bundle to share variables across activities:
this is my main class:
if(liftSelected==true && repsSelected==true){
Intent intent = new Intent (this, Log.class);
intent.putExtra("benchRange", benchRangeString);
this.startActivity(intent);
this is the class i want to share the variable benchRangeString to:
public class Log extends Activity{
TextView benchRange;
String benchRangeString;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.log);
Bundle bundle = getIntent().getExtras();
benchRangeString=bundle.getString("benchRangeString");
benchRange = (TextView)findViewById(R.id.benchRange);
benchRange.setText(benchRangeString);
benchRange.setTextColor(Color.WHITE);
it doesn’t work though. any tips on why this isn’t working the way i expect it to?
Change
to
You can also use: