![](/img/trans.png)
[英]'MainActivity()' cannot be applied to '(android.content.Intent)'
[英]Android: Intent not fetching data to the mainactivity
我有2個活動,從第二個Activity
的OnCreate
開始:
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);
在第一個Activity
,我試圖獲取此getPass1
,但它總是給我-1
。 我在這里想念什么? 這也在MainActivity
OnCreate
中
Intent intent = getIntent();
iSelectedItem = intent.getIntExtra("getPass1", -1);
System.out.println("Password is " + iSelectedItem);
嘗試這個:
Intent intent = getIntent();
iSelectedItem = intent.getExtras().getInt("getPass1", -1);
System.out.println("Password is " + iSelectedItem);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.