ExceptionBrowserpublic class ExceptionBrowser extends android.app.ListActivity
Fields Summary |
---|
private static final String | TAGLogging identifier. | private static final int | UPLOAD_ID | private static final int | CLEAR_ID |
Methods Summary |
---|
protected void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
Cursor cursor = getContentResolver().query(
Checkin.Crashes.CONTENT_URI,
new String[] { Checkin.Crashes._ID, Checkin.Crashes.DATA },
null, null, null);
if (cursor != null) {
startManagingCursor(cursor);
setListAdapter(new CursorAdapter(this, cursor, true) {
public View newView(Context context, Cursor c, ViewGroup v) {
return new CrashListItem(context);
}
public void bindView(View view, Context c, Cursor cursor) {
CrashListItem item = (CrashListItem) view;
try {
String data = cursor.getString(1);
CrashData crash = new CrashData(
new DataInputStream(
new ByteArrayInputStream(
Base64.decodeBase64(data.getBytes()))));
ThrowableData exc = crash.getThrowableData();
item.setText(exc.getType() + ": " + exc.getMessage());
item.setCrashData(crash);
} catch (IOException e) {
item.setText("Invalid crash: " + e);
Log.e(TAG, "Invalid crash", e);
}
}
});
} else {
// No database, no exceptions, empty list.
setListAdapter(new BaseAdapter() {
public int getCount() {
return 0;
}
public Object getItem(int position) {
throw new AssertionError();
}
public long getItemId(int position) {
throw new AssertionError();
}
public View getView(int position, View convertView,
ViewGroup parent) {
throw new AssertionError();
}
});
}
| public boolean | onCreateOptionsMenu(android.view.Menu menu)
super.onCreateOptionsMenu(menu);
menu.add(0, UPLOAD_ID, 0, R.string.menu_upload_exceptions);
menu.add(0, CLEAR_ID, 0, R.string.menu_clear_exceptions);
return true;
| protected void | onListItemClick(ListView l, android.view.View view, int pos, long id)
// TODO: Use a generic VIEW action on the crash's content URI.
CrashData crash = ((CrashListItem) view).getCrashData();
if (crash != null) {
Intent intent = new Intent();
intent.setClass(this, StacktraceViewer.class);
intent.putExtra(
CrashData.class.getName(),
crash.getThrowableData().toString());
startActivity(intent);
}
| public boolean | onOptionsItemSelected(android.view.MenuItem item)
// Handle all of the possible menu actions.
switch (item.getItemId()) {
case UPLOAD_ID:
sendBroadcast(new Intent(Checkin.TriggerIntent.ACTION));
break;
case CLEAR_ID:
getContentResolver().delete(
Checkin.Crashes.CONTENT_URI, null, null);
break;
}
return super.onOptionsItemSelected(item);
|
|