Android Programming Tutorials

(Romina) #1
Your Friends Seem Remote

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;


try {
service.removeAccount(listener);
service.registerAccount(prefs.getString("user", ""),
prefs.getString("password", ""),
listener);
}
catch (Throwable t) {
Log.e("Patchy", "Exception in resetClient()", t);
goBlooey(t);
}
}


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);


builder
.setTitle("Exception!")
.setMessage(t.toString())
.setPositiveButton("OK", null)
.show();
}


private View.OnClickListener onSend=new View.OnClickListener() {
public void onClick(View v) {
updateStatus();
}
};


private SharedPreferences.OnSharedPreferenceChangeListener prefListener=


212
Free download pdf