I was trying pass an int variable from one activity class(A) to another activity class(B). As I am a beginner, I am stuck here.
I have tried many methods but each time I run the code in debug mode , I can see that the int value which I have passed into the second class turns to 0.
Code for Activity A
public void startMainActivity(View view)
{
//Sending the semester value to Navdrawer
Intent intentsem = new Intent(LoginActivity.this, NavDrawer.class);
intentsem.putExtra("UserSemester", usersemester);
startActivity(intentsem);
//Sending the branch value to Navdrawer
Intent intentbranch= new Intent(LoginActivity.this, NavDrawer.class);
intentbranch.putExtra("UserBranch", userbranch);
startActivity(intentbranch);
}
Code for Activity B
public void startSyllabusactivity(View view)
{
// for first year
int semester = getIntent().getIntExtra("UserSemester", 0);
if (semester==1 || semester==2) {
Intent l = new Intent(this, firstyear_syllabussubject_selector.class);
startActivity(l);
}
//rest of the actions with branches to be added***********************
}