Android Programming Tutorials

(Romina) #1
Opening a JAR

client=null;
}

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=
new SharedPreferences.OnSharedPreferenceChangeListener() {
public void onSharedPreferenceChanged(SharedPreferences sharedPrefs, String
key) {
if (key.equals("user") || key.equals("password")) {
resetClient();
}
}
};
}

Extra Credit................................................................................................


Here are some things you can try beyond those step-by-step instructions:



  • Add a checkbox to toggle whether the activity is creating a direct
    message or a status update. If the checkbox is checked, enable a


Spinner containing the list of the user's followers (obtained from
getFollowers()). For a direct message, use sendMessage() on the

174
Free download pdf