-1

i am developing an android application which call my Starting activity from another activity. since i am calling my 1st activity i cannot use intent to transfer a Boolean variable so i created a object of my calling activity and accessed data though it. like this

Activity1 log=new Activity1();
boolean stat=log.aResponse;

i checked the value of aResponse in my Activity1 its value is true. but in my starting activity the value of stat is false all the time. I tried the same code in another activity(which is not my 1st activity) in that also the value i obtain is false. anybody please help me.

2 Answers2

1

you can simply call your launching activity by this:

Intent i = new Intent(Activity1.this, StartingActivity.class);
i.putExtra("varName", variable);//values you want to carry
startActivity(i);
Vikram Singh
  • 1,435
  • 14
  • 19
0

This is a bad way to this. You should go back to basics. Workflow should go like this:

Intent i = new Intent(this, YourNextActivity.class);
i.putExtra("varName", variable);
startActivity(i);

Then to get the value in YourNextActivity:

boolean defaultValue = false;
boolean varName = getIntent().getBooleanExtra("varName",defaultValue)
xklakoux
  • 618
  • 5
  • 11
  • i have i have tried that. if do this my application crashes, because Activity1 is calling the launching activity of my app – NITHIN SUHAS Jun 06 '16 at 12:16