List of usage examples for android.content ClipboardManager setPrimaryClip
public void setPrimaryClip(@NonNull ClipData clip)
From source file:com.raza.betternts.activities.TabFragment2.java
private void menuOption(Cursor cursor, int selectedOption) { String name = cursor.getString(cursor.getColumnIndex(DbSchema.COL_NAME)); String url = cursor.getString(cursor.getColumnIndex(DbSchema.COL_URL)); switch (selectedOption) { //Open in browser case 0: {//from ww w. j a v a2s .c o m Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(browse); break; } //Copy to clipboard case 1: { ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(name, url); clipboard.setPrimaryClip(clip); Toast.makeText(getContext(), "Link copied to clipboard", Toast.LENGTH_SHORT).show(); break; } //Share case 2: { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, url); sendIntent.setType("text/plain"); startActivity(sendIntent); break; } case 3: { moveToMain(cursor); Toast.makeText(getContext(), name + "\nrestored to Vacancies tab", Toast.LENGTH_SHORT).show(); } } }
From source file:org.secuso.privacyfriendlypasswordgenerator.dialogs.GeneratePasswordDialog.java
public void passwordToClipboard(boolean clipboardEnabled, String password) { if (clipboardEnabled) { ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("Password", password); clipboard.setPrimaryClip(clip); Toast.makeText(getActivity(), getActivity().getString(R.string.password_copied), Toast.LENGTH_SHORT) .show();//from ww w .j av a 2 s . c o m } }
From source file:test.ya.translater.wgjuh.yaapitmvptest.view.fragments.translate.fragment.TranslateFragment.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); translatePresenterImpl = new TranslatePresenterImpl(ModelImpl.getInstance(), EventBusImpl.getInstance()); translatePresenterImpl.onBindView(this); viewAdapter = new DictionaryTranslateRecyclerViewAdapter(translatePresenterImpl.getDictionaryState(), getActivity());/* w w w . j a va 2 s . co m*/ translatePresenterImpl.restoreState(); recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext())); recyclerView.setAdapter(viewAdapter); DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), LinearLayout.VERTICAL); recyclerView.addItemDecoration(dividerItemDecoration); btnFavorite.setOnClickListener(btn -> { if (btnFavorite.isChecked()) { translatePresenterImpl.addFavorite(); } else { translatePresenterImpl.deleteFavorite(); } }); btn_retry.setOnClickListener(btn_retry -> translatePresenterImpl.startRetry()); translate.setOnClickListener(textView -> { ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(((TextView) textView).getText(), ((TextView) textView).getText()); clipboard.setPrimaryClip(clip); Toast.makeText(getActivity().getApplicationContext(), getActivity().getResources().getText(R.string.copy_to_clipdoard), Toast.LENGTH_SHORT).show(); }); }
From source file:com.mobshep.mobileshepherd.BrokenCrypto.java
public void copyMessage1(View v) { String copiedMessage = messageOne.getText().toString(); ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("message1", copiedMessage); clipboard.setPrimaryClip(clip); showToast();//from ww w .j a va2s . c o m }
From source file:com.mobshep.mobileshepherd.BrokenCrypto.java
public void copyMessage2(View v) { String copiedMessage2 = messageTwo.getText().toString(); ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("message2", copiedMessage2); clipboard.setPrimaryClip(clip); showToast();/* w w w .j av a 2s . c o m*/ }
From source file:com.mobshep.mobileshepherd.BrokenCrypto.java
public void copyMessage3(View v) { String copiedMessage3 = messageThree.getText().toString(); ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("message3", copiedMessage3); clipboard.setPrimaryClip(clip); showToast();/*from w w w. ja v a2 s .co m*/ }
From source file:com.mobshep.mobileshepherd.BrokenCrypto.java
public void copyMessage4(View v) { String copiedMessage4 = messageFour.getText().toString(); ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("message4", copiedMessage4); clipboard.setPrimaryClip(clip); showToast();// w ww .j a va2 s. c o m }
From source file:com.mobshep.mobileshepherd.BrokenCrypto.java
public void copyMessage5(View v) { String copiedMessage5 = messageFive.getText().toString(); ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("message5", copiedMessage5); clipboard.setPrimaryClip(clip); showToast();/*w w w .j a v a 2 s .c o m*/ }
From source file:net.oremland.rss.reader.fragments.BrowserFragment.java
private void copyUrlToClipboard() { ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("Feed Item Url", getFeedItem().getUrl()); clipboard.setPrimaryClip(clip); Toast.makeText(getContext(), "Url Copied To Clipboard", Toast.LENGTH_SHORT).show(); }
From source file:net.vivekiyer.GAL.Configure.java
@SuppressWarnings("deprecation") @TargetApi(11)/*from w w w.jav a 2s .co m*/ @Override public void onChoiceDialogOptionPressed(int action) { switch (action) { case android.R.id.copy: if (Utility.isPreHoneycomb()) { final android.text.ClipboardManager clipboard; clipboard = (android.text.ClipboardManager) getSystemService( android.content.Context.CLIPBOARD_SERVICE); clipboard.setText(activeSyncManager.getDeviceId()); } else { ClipboardManager clip = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clip.setPrimaryClip(ClipData.newPlainText("Android Device ID", activeSyncManager.getDeviceId())); //$NON-NLS-1$ } break; } }