super.onCreate(savedInstanceState);
// Open a connection to the Google Login Service. Return the account.
mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
mGls = IGoogleLoginService.Stub.asInterface(service);
}
public void onServiceDisconnected(ComponentName className) {
mGls = null;
}
};
bindService(GoogleLoginServiceConstants.SERVICE_INTENT,
mConnection, Context.BIND_AUTO_CREATE);
setContentView(R.layout.gls_tester);
mText = (LogTextBox) findViewById(R.id.text);
mText.append("Hello, world!\n");
Log.v(TAG, "hello, world!");
mDoNotify = (CheckBox) findViewById(R.id.do_notification);
mRunIntent = (CheckBox) findViewById(R.id.run_intent);
mRunIntent.setChecked(true);
mService = (Spinner) findViewById(R.id.service_spinner);
mUsernameEdit = (EditText) findViewById(R.id.username_edit);
Button b;
b = (Button) findViewById(R.id.require_google);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
String account = mGls.getAccount(GoogleLoginServiceConstants.REQUIRE_GOOGLE);
mText.append("REQUIRE_GOOGLE gave: " + account + "\n");
mUsernameEdit.setText(account == null ? "" : account);
} catch (RemoteException e) {
mText.append("exception: " + e + "\n");
}
} });
b = (Button) findViewById(R.id.prefer_hosted);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
String account = mGls.getAccount(GoogleLoginServiceConstants.PREFER_HOSTED);
mText.append("PREFER_HOSTED gave: " + account + "\n");
mUsernameEdit.setText(account == null ? "" : account);
} catch (RemoteException e) {
mText.append("exception: " + e + "\n");
}
} });
b = (Button) findViewById(R.id.get_accounts);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
String[] accounts = mGls.getAccounts();
mText.append("account list: (" + accounts.length + " entries)\n");
for (String username: accounts) {
mText.append(" " + username + "\n");
}
} catch (RemoteException e) {
mText.append("exception: " + e + "\n");
}
} });
b = (Button) findViewById(R.id.clear);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mText.setText("");
} });
b = (Button) findViewById(R.id.go);
b.setOnClickListener(new Listener());
b = (Button) findViewById(R.id.wipe_passwords);
b.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mText.setText("wiping passwords:\n");
try {
String[] accounts = mGls.getAccounts();
LoginData ld = new LoginData();
for (String username: accounts) {
ld.mUsername = username;
mGls.updatePassword(ld);
mText.append(" " + username + "\n");
}
mText.append("done.\n");
} catch (RemoteException e) {
mText.append("caught exception " + e + "\n");
}
} });