I have 2 Activities, from the second Activity
's OnCreate
I am doing this:
setPassButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(getPass1 == getPass2) {
Intent gotoMain = new Intent(FirstRun.this, MainActivity.class);
gotoMain.putExtra("getPass1", getPass1);
startActivity(gotoMain);
In the first Activity
, I am trying to fetch this getPass1
, but it always gives me -1
. What am I missing here? This is also in OnCreate
of the MainActivity
Intent intent = getIntent();
iSelectedItem = intent.getIntExtra("getPass1", -1);
System.out.println("Password is " + iSelectedItem);
Try this:
Intent intent = getIntent();
iSelectedItem = intent.getExtras().getInt("getPass1", -1);
System.out.println("Password is " + iSelectedItem);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.