Example usage for android.content Context CLIPBOARD_SERVICE

List of usage examples for android.content Context CLIPBOARD_SERVICE

Introduction

In this page you can find the example usage for android.content Context CLIPBOARD_SERVICE.

Prototype

String CLIPBOARD_SERVICE

To view the source code for android.content Context CLIPBOARD_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.content.ClipboardManager for accessing and modifying the contents of the global clipboard.

Usage

From source file:piuk.blockchain.android.ui.SendingAddressesFragment.java

private void handleCopyToClipboard(final String address) {
    ClipboardManager clipboardManager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
    clipboardManager.setText(address);/*from   www.  jav  a 2  s. c  o  m*/
    ((AbstractWalletActivity) activity).toast(R.string.wallet_address_fragment_clipboard_msg);
}

From source file:com.ecuamobi.deckwallet.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_donate) {
        try {/*  w  w  w.j  a v  a 2  s  . co  m*/
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(SCHEME_BITCOIN + ADDRESS_DONATE));
            startActivity(intent);
        } catch (Exception e) {
            ((ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE))
                    .setPrimaryClip(ClipData.newPlainText(getString(R.string.address), ADDRESS_DONATE));

            Util.showToast(this, R.string.donate_copied);
        }
        return true;
    }
    if (id == R.id.action_help) {
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(HELP_URL));
            startActivity(intent);
        } catch (Exception e) {
        }
        return true;
    }
    if (id == R.id.action_rate) {
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(MARKET_PREFIX_LOCAL + PACKAGE));
            startActivity(intent);
        } catch (Exception e) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(MARKET_PREFIX_REMOTE + PACKAGE));
            startActivity(intent);
        }
        return true;
    }
    if (id == R.id.action_clear) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.clear);
        builder.setMessage(R.string.clear_confirm);
        builder.setNegativeButton(R.string.no, null);
        builder.setPositiveButton(R.string.yes, new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                clear();
            }
        });
        builder.show();
        return true;
    }
    if (id == R.id.action_check) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.check);
        builder.setMessage(R.string.check_confirm);
        builder.setNegativeButton(R.string.no, null);
        builder.setPositiveButton(R.string.yes, new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                final String seed = temporalSeed;
                init(null);
                showFinalMenuItems(false);
                lastSeed = seed;
                Util.showToast(MainActivity.this, R.string.reenter_check, Toast.LENGTH_LONG);
            }
        });
        builder.show();
        return true;
    }
    if (id == R.id.action_share) {
        new GetAllAddresses().execute();
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.javielinux.utils.TweetActions.java

public static void copyToClipboard(FragmentActivity activity, InfoTweet infoTweet) {
    try {/*from w ww  . ja v  a2  s  . co m*/
        ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
        clipboard.setText(infoTweet.getText());
        Utils.showMessage(activity, activity.getString(R.string.copied_to_clipboard));
    } catch (NoClassDefFoundError e) {
        Utils.showMessage(activity, activity.getString(R.string.error_general));
        e.printStackTrace();
    }
}

From source file:com.microsoft.o365_android_onenote_rest.SnippetDetailFragment.java

@TargetApi(11)
private void clipboard11(TextView tv) {
    android.content.ClipboardManager clipboardManager = (android.content.ClipboardManager) getActivity()
            .getSystemService(Context.CLIPBOARD_SERVICE);
    ClipData clipData = ClipData.newPlainText("OneNote", tv.getText());
    clipboardManager.setPrimaryClip(clipData);
}

From source file:com.raza.betternts.activities.TabFragment1.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  w w  w . j av  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: {
        moveToIgnored(cursor);
        Toast.makeText(getContext(), name + "\nremoved to ignored posts", Toast.LENGTH_SHORT).show();
        break;
    }
    }
}

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);//from  w w  w  .j a  v  a2 s.  com

    showToast();

}

From source file:de.kodejak.hashr.fragmentHashFromText.java

public void OnButtonFromClipboardClick() {
    EditText txtOutput = (EditText) getView().findViewById(R.id.edCompare);
    ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
    CharSequence hash = clipboard.getText();
    String out = (String) hash;

    if (trimHash)
        out = out.trim();//from   w ww . java  2s .  c  om

    if (uppercaseHash) {
        out = out.toUpperCase();
    }

    txtOutput.setText(out);
}

From source file:org.gdgsp.fragment.EventFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_share:
        Intent sharePageIntent = new Intent();
        sharePageIntent.setAction(Intent.ACTION_SEND);
        sharePageIntent.putExtra(Intent.EXTRA_TEXT, event.getName() + " " + event.getLink());
        sharePageIntent.setType("text/plain");
        startActivity(Intent.createChooser(sharePageIntent, getResources().getText(R.string.share)));
        return true;
    case R.id.menu_people:
        Intent intent = new Intent(activity, PeopleActivity.class);
        intent.putExtra("event", event);
        startActivity(intent);/*  w w  w .  j  a va2s. c o  m*/
        return true;
    case R.id.menu_copylink:
        if (Build.VERSION.SDK_INT <= 10) {
            android.text.ClipboardManager clipboard = (android.text.ClipboardManager) activity
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            clipboard.setText(event.getLink());
        } else {
            ClipboardManager clipboardManager = (ClipboardManager) activity
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clipData = ClipData.newPlainText(event.getLink(), event.getLink());
            clipboardManager.setPrimaryClip(clipData);
        }
        Other.showToast(activity, getString(R.string.link_copyed));
        return true;
    case R.id.menu_openinbrowser:
        Other.openSite(activity, event.getLink());
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.fbbackup.ImageDetailActivity.java

private void setListener() {
    btn_share.setOnClickListener(new Button.OnClickListener() {

        @Override//w  ww  .  ja v a 2  s  . c  o  m
        public void onClick(View v) {
            // TODO Auto-generated method stub
            // Gets a handle to the clipboard service.
            ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
            clipboard.setText(clipBoardText);

            PackageManager pm = getPackageManager();
            Intent intent = pm.getLaunchIntentForPackage("jp.naver.line.android");

            File file = new File(extStorageDirectory + "/DCIM/FBBackup/test.jpg");

            Uri outputFileUri = Uri.fromFile(file);

            String[] path = { extStorageDirectory + "/DCIM/FBBackup/test.jpg" };
            //            MediaScannerConnection.scanFile(this, path, null,  
            //                  new MediaScannerConnection.OnScanCompletedListener() {
            //                  public void onScanCompleted(String path, Uri uri) {
            //                      Log.i("ExternalStorage", "Scanned " + path + ":");
            //                      Log.i("ExternalStorage", "-> uri=" + uri);
            //                  }
            //            });

            MediaScannerConnection.scanFile(getApplicationContext(), path, null, null);

            Log.w("RyanWang", outputFileUri.getPath());

            intent.setAction(Intent.ACTION_SEND);
            intent.putExtra(Intent.EXTRA_STREAM, outputFileUri);
            intent.setType("image/jpeg");

            startActivity(intent);

        }

    });

    btn_download_photo.setOnClickListener(new ImageButton.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            DownloadSinglePicTask download = new DownloadSinglePicTask();

            download.setContext(ImageDetailActivity.this);

            download.setAlbunPhotoUrl(clipBoardText);

            Log.w("downloadpic", "ImageDetail albumName:" + albumName);

            download.setPath(
                    extStorageDirectory + "/DCIM/FBBackup/" + name + "/" + Utils.getDirName(albumName) + "/");

            download.execute("test");
        }

    });
}

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);/*  w  w  w  .ja v a  2 s . c o m*/

    showToast();

}