Passing Intent can't get extra();

后端 未结 4 1459
独厮守ぢ
独厮守ぢ 2021-01-16 17:08

Hi i can\'t get logged in already in a web page at mine main activity i passed inten to another activity but i can\'t get an extract. How can i solve it

this is min

4条回答
  •  庸人自扰
    2021-01-16 17:25

    Try this way,hope this will help you to solve your problem.

    There is two way pass/get data one activity to another activity.

    1.add data to intent.

    how to put :

    Intent goToNextActivity = new Intent();
    goToNextActivity.putExtra("username", user_name);
    goToNextActivity.putExtra("password", pass_word);
    

    how to get :

    String username = getIntent().getStringExtra("username");
    String password = getIntent().getStringExtra("password");
    

    2.Add data to bundle and add bundle to intent.

    how to put :

    Intent goToNextActivity = new Intent();
    Bundle bundle = new Bundle();
    bundle.putString("username", user_name);
    bundle.putString("password", pass_word);
    goToNextActivity.putExtras(bundle);
    

    how to get :

    String username = getIntent().getExtras().getString("username");
    String password = getIntent().getExtras().getString("password");
    

提交回复
热议问题