Here’s the scenario.
I have:
A LOGIN activity
A SESSION where I have methods getUsername() and setUsername()
A GET activity where it is supposed to get the username.
Upon successful login in the Login Activity I have this line of code
public class MainActivity extends Activity {
Session obj = new Session();
and then in another method called tryLogin() i have this
obj.setUsername(mUsername);
In Session activity I have these codes:
public class Session extends Application {
String username;
int userid;
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
}
public void setUsername(String user)
{
this.username = user;
}
public String getUsername()
{
return this.username;
}
and in the Activity that gets the username I have this line.
Session obj = new Session();
username = obj.getUsername();
This doesn’t work properly. BUT if I manually set the ‘username’ to some string in the SESSION activity like this:
public class Session extends Application {
String username = "manually set the string";
Then the GET Activity gets the username just fine.
So I think it’s safe to narrow down the issue to the setUsername from the login activity.
So what am i doing wrong here?
Thank you so much.
//
Android Beginner
Try:
in your Session Activity.