I'm building an app with a Login area. I'm using PHP to insert the Values from my Application into my database, I'm using parameters.
I would like to get the information from the user, when he logs in, so, i already got the the ID from the user, and I would like to put the ID inside a variable, and create a session to call everytime that the user visits his profile.
The user will do the Login inside the Mainactivity
Mainactivity
public void login(View view){
String username = usernameField.getText().toString();
String password = passwordField.getText().toString();
new SigninActivity(this,status,role,0).execute(username,password);
}
class Session {
public String username = "I WILL PUT THE USERNAME OR ID HERE";
}
class App extends Application {
Session session = new Session();
public String getUsername() {
return session.username;
}
public void setUsername(String username) {
session.username = username;
}
}
And now, I'm trying to call the string username in other activity named test.
test
public class test extends Activity{
private TextView get;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.teste);
get = (TextView)findViewById(R.id.get);
App app = (App) getApplication();
String username = app.getUsername();
if (username.equals("")) {
// the user is not logged in, do something
}
}
}
I inserted that in android manifest
<activity
android:name=".test"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
But when i open the test activity i receive multiple errors. What am i doing wrong?