Android Programming Tutorials

(Romina) #1
No, Really Listening To Your Friends

service.removeAccount(listener);
unbindService(svcConn);
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
new MenuInflater(getApplication())
.inflate(R.menu.option, menu);


return(super.onCreateOptionsMenu(menu));
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId()==R.id.prefs) {
startActivity(new Intent(this, EditPreferences.class));


return(true);
}


return(super.onOptionsItemSelected(item));
}


synchronized private Twitter getClient() {
if (client==null) {
client=new Twitter(prefs.getString("user", ""),
prefs.getString("password", ""));
client.setAPIRootUrl("https://identi.ca/api");
}


return(client);
}


synchronized private void resetClient() {
client=null;
service.removeAccount(listener);
service.registerAccount(prefs.getString("user", ""),
prefs.getString("password", ""),
listener);
}


private^ void^ updateStatus() {
try {
getClient().updateStatus(status.getText().toString());
}
catch (Throwable t) {
Log.e("Patchy", "Exception in updateStatus()", t);
goBlooey(t);
}
}


private void goBlooey(Throwable t) {
AlertDialog.Builder builder=new AlertDialog.Builder(this);


195
Free download pdf