Android : How to make a parse.com log out button to take me to another activity which lets me either log in or sign up?

on Saturday, December 13, 2014


i have an activity that lets me sign up or simply log in, when the user has been logged in, four fragments, which can be navigated through scrollable tabs are displayed, the last fragment has a log out button, i need that log out button to 1)log out directly from parse.com and 2)get the user to the activity where they can sign up or sign in.


This is the code that i have so far


THIS IS THE SIGN IN OR SIGN UP ACTIVITY



@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.signup_or_login);

// Log in button click handler
((Button) findViewById(R.id.login)).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Starts an intent of the log in activity
startActivity(new Intent(SignUpOrLogInActivity.this, LoginActivity.class));
}
});

// Sign up button click handler
((Button) findViewById(R.id.signup)).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Starts an intent for the sign up activity
startActivity(new Intent(SignUpOrLogInActivity.this, SignUpActivity.class));
}
});
}


THIS IS THE SET UP FRAGMENT WHERE THE LOG OUT BUTTON IS LOCATED


@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { return inflater.inflate(R.layout.setup_fragment,container,false); }



@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

logout = (Button) getView().findViewById(R.id.logout_button);

// Logout Button Click Listener
logout.setOnClickListener(new OnClickListener() {

public void onClick(View view) {
// Logout current user
ParseUser.logOut();
startActivity(new Intent(getActivity(), SignUpOrLogInActivity.class));

}

});

}


}


The problems are 1)that when i run the app, it first starts at the scrollable tabs (the fragments) and not at the sign in or sign up activity and 2)when i go to the set up fragment where the log out button is located the app crashes and a message is displayed saying "unfortunately your app has stopped.


HERE IS THE MANIFEST


THANKS FOR TAKING THE TIME FOR READING THIS I REALLY APPRECIATE IT.


0 comments:

Post a Comment