Set and get username between activities
<p>Here's the scenario.
I have:</p>

<p>A LOGIN activity</p>

<p>A SESSION where I have methods getUsername() and setUsername()</p>

<p>A GET activity where it is supposed to get the username.</p>

<p>Upon successful login in the Login Activity I have this line of code</p>

<pre><code>public class MainActivity extends Activity {
Session obj = new Session();
</code></pre>

<p>and then in another method called tryLogin() i have this</p>

<pre><code>obj.setUsername(mUsername);
</code></pre>

<p>In Session activity I have these codes:</p>

<pre><code>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;
}
</code></pre>

<p>and in the Activity that gets the username I have this line.</p>

<pre><code>    Session obj = new Session();
    username =  obj.getUsername();
</code></pre>

<p>This doesn't work properly. BUT if I manually set the 'username' to some string in the SESSION activity like this:</p>

<pre><code>public class Session extends Application {
    String username = "manually set the string";
</code></pre>

<p>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. </p>

<p>So what am i doing wrong here?</p>

<p>Thank you so much.
//
Android Beginner</p>
