I would like to view some text in Toast after a new Intent activity is being used.
This is what I have:
Intent i = new Intent(this, PrivateWallet.class);
startActivity(i);
this.finish();
Toast.makeText(getApplicationContext(), "You have € " + inputTransacVal.getText().toString() + " less.",Toast.LENGTH_SHORT).show();
The problem is, that Toast is showing some text first, before intent is starting.
Any help would be much appreciated. 🙂
Edit:
Here is the working code:
Bundle bundle = new Bundle(); bundle.putString("value", "You have € " + inputTransacVal.getText().toString() + " more.");
startActivity(new Intent(this, PrivateWallet.class).putExtras(bundle));
this.finish();
This code is meant to validate:
if(this.getIntent().getExtras() != null){
Toast.makeText(this, this.getIntent().getExtras().getString("value"),Toast.LENGTH_LONG).show();
}
You should definitively put the Toast code in the onCreate of your PrivateWallet activity.
The amount of Euro should be passed to your activity with a Bundle:
and then in your PrivateWallet Activity: