List of usage examples for android.content Context CLIPBOARD_SERVICE
String CLIPBOARD_SERVICE
To view the source code for android.content Context CLIPBOARD_SERVICE.
Click Source Link
From source file:com.google.android.gcm.demo.ui.AbstractFragment.java
@Override public boolean onLongClick(View v) { // Copy in the clipboard the value of the selected widget. String value = getValue(v.getId()); if (value.length() > 0) { ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip(ClipData.newPlainText("GcmTestApp clipboard", value)); Toast.makeText(getActivity(), value + "\nhas been copied in the clipboard", Toast.LENGTH_SHORT).show(); return true; }// ww w. j av a2s. c o m return false; }
From source file:com.xw.project.gracefulmovies.view.activity.AboutActivity.java
@OnClick({ R.id.about_gmail_img, R.id.about_github_img, R.id.about_license_text }) public void onClick(View view) { switch (view.getId()) { case R.id.about_gmail_img: String s1 = ""; String s2 = getString(R.string.gmail_address); ClipboardManager cmb = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clipData = ClipData.newPlainText("content", s2); cmb.setPrimaryClip(clipData);/* w w w . j a va 2 s. c om*/ showToast(getString(R.string.hint_clipboard, s1, s2)); break; case R.id.about_github_img: Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(getString(R.string.github_page))); startActivity(Intent.createChooser(intent, "?")); break; case R.id.about_license_text: navigateTo(OpenLicenseActivity.class); break; } }
From source file:com.softminds.matrixcalculator.OperationFragments.NormOne.java
@Override public void onListItemClick(ListView L, View V, int position, long id) { final int pos = position; final android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder( getContext());//from w w w. j av a2 s . co m builder.setPositiveButton(R.string.copy, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { ClipboardManager clipboardManager = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clipData = ClipData.newPlainText("NORM_ONE_RES", GetText( ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(pos).getNorm1())); clipboardManager.setPrimaryClip(clipData); if (clipboardManager.hasPrimaryClip()) { Toast.makeText(getContext(), R.string.CopyToClip, Toast.LENGTH_SHORT).show(); } else Log.d("ClipData", "Failed to set to Clip board"); dialogInterface.dismiss(); } }); builder.setNeutralButton(R.string.Done, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }); builder.setMessage("First Norm is : " + GetText( ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(position).getNorm1())); builder.setTitle(R.string.normOne); builder.setCancelable(false); builder.show(); }
From source file:com.softminds.matrixcalculator.OperationFragments.NormTwo.java
@Override public void onListItemClick(ListView L, View V, int position, long id) { final int pos = position; final android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder( getContext());// w ww . j a va2s.com builder.setPositiveButton(R.string.copy, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { ClipboardManager clipboardManager = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clipData = ClipData.newPlainText("NORM_TWO_RES", GetText( ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(pos).getNorm2())); clipboardManager.setPrimaryClip(clipData); if (clipboardManager.hasPrimaryClip()) { Toast.makeText(getContext(), R.string.CopyToClip, Toast.LENGTH_SHORT).show(); } else Log.d("ClipData", "Failed to set to Clip board"); dialogInterface.dismiss(); } }); builder.setNeutralButton(R.string.Done, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }); builder.setMessage("Second Norm is : " + GetText( ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(position).getNorm2())); builder.setTitle(R.string.normTwo); builder.setCancelable(false); builder.show(); }
From source file:com.softminds.matrixcalculator.OperationFragments.NormFreb.java
@Override public void onListItemClick(ListView L, View V, int position, long id) { final int pos = position; final android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder( getContext());//from w w w . j a va 2 s . com builder.setPositiveButton(R.string.copy, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { ClipboardManager clipboardManager = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clipData = ClipData.newPlainText("NORM_FREB_RES", GetText(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(pos) .getNormFrobenious())); clipboardManager.setPrimaryClip(clipData); if (clipboardManager.hasPrimaryClip()) { Toast.makeText(getContext(), R.string.CopyToClip, Toast.LENGTH_SHORT).show(); } else Log.d("ClipData", "Failed to set to Clip board"); dialogInterface.dismiss(); } }); builder.setNeutralButton(R.string.Done, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }); builder.setMessage("Frebenious Norm is : " + GetText(((GlobalValues) getActivity().getApplication()) .GetCompleteList().get(position).getNormFrobenious())); builder.setTitle(R.string.normFreb); builder.setCancelable(false); builder.show(); }
From source file:com.softminds.matrixcalculator.OperationFragments.NormInfinity.java
@Override public void onListItemClick(ListView L, View V, int position, long id) { final int pos = position; final android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder( getContext());//from ww w. j a va2 s. co m builder.setPositiveButton(R.string.copy, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { ClipboardManager clipboardManager = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clipData = ClipData.newPlainText("NORM_INFINITY_RES", GetText(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(pos) .getNormInfinity())); clipboardManager.setPrimaryClip(clipData); if (clipboardManager.hasPrimaryClip()) { Toast.makeText(getContext(), R.string.CopyToClip, Toast.LENGTH_SHORT).show(); } else Log.d("ClipData", "Failed to set to Clip board"); dialogInterface.dismiss(); } }); builder.setNeutralButton(R.string.Done, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }); builder.setMessage("Infinity Norm is : " + GetText( ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(position).getNormInfinity())); builder.setTitle(R.string.normInfinity); builder.setCancelable(false); builder.show(); }
From source file:org.jboss.aerogear.crypto.android.demo.fragments.DetailFragment.java
private void copyToClipboard(String password) { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(password);//from w ww. j a v a 2 s . c o m } else { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newPlainText(getString(R.string.password), password); clipboard.setPrimaryClip(clip); } }
From source file:com.coloreight.plugin.clipboard.Clipboard.java
public void paste(final CallbackContext callbackContext) { cordova.getActivity().runOnUiThread(new Runnable() { public void run() { ClipboardManager clipboard = (ClipboardManager) cordova.getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); if (!clipboard.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.NO_RESULT)); }/*from w ww . ja v a 2s.c o m*/ try { ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0); String text = item.getText().toString(); callbackContext.success(text); } catch (Exception e) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, e.toString())); } } }); }
From source file:cc.mintcoin.wallet.ui.SendingAddressesFragment.java
@Override public void onAttach(final Activity activity) { super.onAttach(activity); this.activity = (AbstractWalletActivity) activity; this.clipboardManager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); this.loaderManager = getLoaderManager(); }
From source file:com.feathercoin.wallet.feathercoin.ui.SendingAddressesFragment.java
@Override public void onAttach(final Activity activity) { super.onAttach(activity); this.activity = (AbstractWalletActivity) activity; // This works for both clipboard managers because android.content.ClipboardManager is subclassed from the old one. this.clipboardManager = (android.text.ClipboardManager) activity .getSystemService(Context.CLIPBOARD_SERVICE); this.loaderManager = getLoaderManager(); }