Skip to content

Instantly share code, notes, and snippets.

@smaspe
Created June 10, 2013 16:31
Show Gist options
  • Save smaspe/5750175 to your computer and use it in GitHub Desktop.
Save smaspe/5750175 to your computer and use it in GitHub Desktop.
public class RestrictedActivity extends LoginableActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!loggedIn) {
login(null);
} else {
startup();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (loggedIn) {
startup();
} else {
Toast.makeText(this, "Login canceled", Toast.LENGTH_SHORT).show();
finish();
}
}
private void startup() {
setContentView(R.layout.activity_restricted);
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment