ClipboardManager getText - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ClipboardManager getText method.

This code example shows how to use the following methods:getText, hasText
    } 
 
    @Override 
    public String getText() {
        final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
        if ( clipboard.hasText() ) {
            return String.valueOf(clipboard.getText());
        } else { 
            return null; 
        } 
    } 
 
    @Override 
    public void setText(@NotNull String text) {
        final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
        clipboard.setText(text);
    } 
 
    @Override 
    public void setText(@NotNull CharSequence text) {
6
CodeRank
This code example shows how to use the following methods:getText
import android.widget.TextView; 
 
public class Util { 
	public static String getClipboard(Context context) {
		ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
		return clipboard.getText().toString();
	} 
	 
	public static void copyToClipboard(Context context, String text) throws SamsungClipboardException {
		ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
		 
		try { 
			clipboard.setText(text);
		} catch (NullPointerException e) {
			throw new SamsungClipboardException(e);
		} 
	} 
	 
	public static void gotoUrl(Context context, String url) throws ActivityNotFoundException {
		if ( url != null && url.length() > 0 ) {
6
CodeRank
This code example shows how to use the following methods:getText, hasText
	public void setText(CharSequence text) {
		cbV3.setText(text);
	} 
 
	public CharSequence getText() {
		if (cbV3.hasText())
			return cbV3.getText();
		else 
			return null; 
	} 
} 
6
CodeRank
This code example shows how to use the following methods:getText, hasText, setText
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         
        ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
        if (cm.hasText()) {
        	CharSequence cs = cm.getText();
        	if (cs != null) {
        		String data = cs.toString();
				try { 
					int num = Integer.parseInt(data);
	        		String convertData = String.valueOf(num);
	        		cm.setText(convertData);
	        		showMessage("変換に成功しました。"); 
				} catch (NumberFormatException e) {
					showMessage("数値以外の文字が含まれています。"); 
				} 
        	} 
        } else { 
        	showMessage("クリップボードが空です"); 
5
CodeRank
This code example shows how to use the following methods:getText, hasText, setText
             
            String clipboardPassword = Session.getInstance().getClipboardPassword();
            // We only clear the clipboard when the content equals the last 
            // copied password. 
            if (clipboardPassword != null &&
                cm.hasText() &&
                cm.getText().equals(clipboardPassword)) {
 
                cm.setText("");
                Session.getInstance().setClipboardPassword(null); 
            } 
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getText, hasText
	public void onCreate() { 
		// TODO Auto-generated method stub 
		super.onCreate(); 
		ClipboardManager clipman= (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
		 
		if(clipman.hasText()){
			Toast.makeText(	getApplicationContext(),clipman.getText().toString(),Toast.LENGTH_LONG).show();
		} 
		else {Toast.makeText(getApplicationContext(),"No text",Toast.LENGTH_LONG).show();}
		stopSelf();
		 
	} 
 
	 
		@Override 
		public void onDestroy() { 
			//Toast.makeText(this, "My Service Stopped", Toast.LENGTH_LONG).show(); 
		} 
	 
		 
5
CodeRank
This code example shows how to use the following methods:getText
 
  @SuppressWarnings("deprecation") 
  public String getText() {
    String text = null;
    ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
    text = clipboard.getText().toString();
    return text;
  } 
} 
5
CodeRank
This code example shows how to use the following methods:getText, hasText
This code example shows how to use the following methods:getText
    public void copyText(View view) {
        clipboardManager.setText("Text\nwith\nnewlines");
    } 
 
    public void pasteText(View view) {
        CharSequence text = clipboardManager.getText();
        editText.setText(text);
    } 
} 
4
CodeRank
This code example shows how to use the following methods:getText
 
    //============================================================================== 
    public final String getClipboardContent()
    { 
        ClipboardManager clipboard = (ClipboardManager) getSystemService (CLIPBOARD_SERVICE);
        return clipboard.getText().toString();
    } 
 
    public final void setClipboardContent (String newText)
    { 
        ClipboardManager clipboard = (ClipboardManager) getSystemService (CLIPBOARD_SERVICE);
        clipboard.setText (newText);
    } 
 
    //============================================================================== 
    public final void showMessageBox (String title, String message, final long callback)
    { 
        AlertDialog.Builder builder = new AlertDialog.Builder (this);
        builder.setTitle (title)
               .setMessage (message)
4
CodeRank

Related ClipboardManager getText Questions & Answers:

getText Method Overview
Returns the text on the clipboard.
See Code Examples for other Android ClipboardManager Methods: