Unable to access changed value of variable from another class in android studio

后端 未结 2 1622

I have created two class one is LoginSignupActivity.java and another is ProfileActivity.java

LoginSignUpActivity.java---

        public class LoginSi         


        
相关标签:
2条回答
  • 2020-12-22 07:37

    do as:

    public static  String id="NA";
    
    • Use String instead of string. Android Studio "cannot resolve symbol String"
    • List item

    you will get NA if id is not received by your line of code:

      id=response.getJSONObject().getString("id");
    

    As you told in comment, you should use the value of id after getting it only

     id=response.getJSONObject().getString("id");
    

    I thing you should only start the ProfileActivity.java just after getting id valueas below:

    id=response.getJSONObject().getString("id");
    Intent intent=new Intent(LoginSignupActivity.this,ProfileActivity.class);
    startActivity(intent);
    

    Thanks

    0 讨论(0)
  • 2020-12-22 07:56

    Try to make id public and I think you should get it throw LoginSignUpActivity.id

    If the login is for one time only I recommand you to use SharedPreference.

    0 讨论(0)
提交回复
热议问题