List of usage examples for android.os Message sendToTarget
public void sendToTarget()
From source file:ch.luklanis.esscan.history.HistoryActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.history_menu_send_dta_save: case R.id.history_menu_send_dta_other: case R.id.history_menu_send_dta_email: { Message message = Message.obtain(mDataSentHandler, item.getItemId()); createDTAFile(message);//from w ww . j a v a 2s .co m } break; case R.id.history_menu_send_csv: { CharSequence history = mHistoryManager.buildHistory(); Uri historyFile = HistoryManager.saveHistory(history.toString()); String[] recipients = new String[] { PreferenceManager.getDefaultSharedPreferences(this) .getString(PreferencesActivity.KEY_EMAIL_ADDRESS, "") }; if (historyFile == null) { setOkAlert(R.string.msg_unmount_usb); } else { Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:")); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.putExtra(Intent.EXTRA_EMAIL, recipients); String subject = getResources().getString(R.string.history_email_title); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, subject); intent.putExtra(Intent.EXTRA_STREAM, historyFile); intent.setType("text/csv"); startActivity(intent); } } break; case R.id.history_menu_clear: { new CancelOkDialog(R.string.msg_sure).setOkClickListener(new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { mHistoryManager.clearHistory(); dialogInterface.dismiss(); finish(); } }).show(getFragmentManager(), "HistoryActivity.onOptionsItemSelected"); } break; case android.R.id.home: { int error = PsDetailActivity.savePaymentSlip(this); if (error > 0) { setCancelOkAlert(this, error); return true; } NavUtils.navigateUpTo(this, new Intent(this, CaptureActivity.class)); return true; } case R.id.history_menu_copy_code_row: { PsDetailFragment fragment = (PsDetailFragment) getFragmentManager() .findFragmentById(R.id.ps_detail_container); if (fragment != null) { String completeCode = fragment.getHistoryItem().getResult().getCompleteCode(); addCodeRowToClipboard(completeCode); } } break; case R.id.history_menu_send_code_row: { PsDetailFragment fragment = (PsDetailFragment) getFragmentManager() .findFragmentById(R.id.ps_detail_container); if (fragment != null) { IEsrSender sender = getEsrSender(); if (sender != null) { mSendingProgressDialog.show(); fragment.send(PsDetailFragment.SEND_COMPONENT_CODE_ROW, sender, this.historyFragment.getActivatedPosition()); } else { Message message = Message.obtain(mDataSentHandler, R.id.es_send_failed); message.sendToTarget(); } } } break; default: return super.onOptionsItemSelected(item); } return true; }