The problem is that I can't access the userId variable value from inside the onCreate method. I'm accessing the activity from two different activities so I have to check from which one I'm coming from, I do that with the caller but the value returned by the getDetailsUserId method is 0 all the time even though userId is a class variable.
If I initialize userId with 5 for example that's the value returned by the getDetailsUserId method... not the value from the onCreate method.
public class Details extends Activity {
long userId;
long getDetailsUserId(){
return userId; //This is the variable value I can't get.
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details);
getActionBar().setDisplayHomeAsUpEnabled(true);
final String caller;
//Get previous activity name
caller = getIntent().getStringExtra("com.mysite.myapp.Caller");
//Get user id from "List"
if(caller.equals("List")){
List userListId = new List();
userId = userListId.getUserListId();
}
//Get user id from "Profile Saved"
else if(caller.equals("ProfileSaved")){
ProfileSaved savedUserId = new ProfileSaved();
userId = savedUserId.getSavedUserId();
}
}