@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menuSalin: { if (currentSong != null) { U.copyToClipboard(convertSongToText(currentSong)); Toast.makeText(this, R.string.sn_copied, Toast.LENGTH_SHORT).show(); } } return true; case R.id.menuBagikan: { if (currentSong != null) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); // $NON-NLS-1$ intent.putExtra( Intent.EXTRA_SUBJECT, currentBookName + ' ' + currentSong.code + ' ' + currentSong.title); intent.putExtra(Intent.EXTRA_TEXT, (CharSequence) convertSongToText(currentSong)); startActivityForResult( ShareActivity.createIntent(intent, getString(R.string.sn_share_title)), REQCODE_share); } } return true; } return false; }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQCODE_songList) { if (resultCode == RESULT_OK) { SongListActivity.Result result = SongListActivity.obtainResult(data); if (result != null) { displaySong(result.bookName, S.getSongDb().getSong(result.bookName, result.code)); // store this for next search last_searchState = result.last_searchState; } } } else if (requestCode == REQCODE_share) { if (resultCode == RESULT_OK) { ShareActivity.Result result = ShareActivity.obtainResult(data); if (result != null && result.chosenIntent != null) { startActivity(result.chosenIntent); } } } }