當前位置: 首頁>>代碼示例>>Java>>正文


Java ClipboardManager.getText方法代碼示例

本文整理匯總了Java中android.text.ClipboardManager.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java ClipboardManager.getText方法的具體用法?Java ClipboardManager.getText怎麽用?Java ClipboardManager.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.text.ClipboardManager的用法示例。


在下文中一共展示了ClipboardManager.getText方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onTextContextMenuItem

import android.text.ClipboardManager; //導入方法依賴的package包/類
@SuppressLint("NewApi")
	@Override
    public boolean onTextContextMenuItem(int id) {
        if(id == android.R.id.paste){
            ClipboardManager clip = (ClipboardManager)getContext().getSystemService(Context.CLIPBOARD_SERVICE);
            if (clip == null || clip.getText() == null) {
                return false;
            }
            String text = clip.getText().toString();
            if(text.startsWith(ChatActivity.COPY_IMAGE)){
//                intent.setDataAndType(Uri.fromFile(new File("/sdcard/mn1.jpg")), "image/*");     
                text = text.replace(ChatActivity.COPY_IMAGE, "");
                Intent intent = new Intent(context,AlertDialog.class);
                String str = context.getResources().getString(R.string.Send_the_following_pictures);
                intent.putExtra("title", str);
                intent.putExtra("forwardImage", text);
                intent.putExtra("cancel", true);
                ((Activity)context).startActivityForResult(intent,ChatActivity.REQUEST_CODE_COPY_AND_PASTE);
//                clip.setText("");
            }
        }
        return super.onTextContextMenuItem(id);
    }
 
開發者ID:tengbinlive,項目名稱:info_demo,代碼行數:24,代碼來源:PasteEditText.java

示例2: doPaste

import android.text.ClipboardManager; //導入方法依賴的package包/類
private void doPaste() {
    ClipboardManager clip = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
    if(!clip.hasText()){
        Toast tt = Toast.makeText(this, "No text to Paste..", Toast.LENGTH_SHORT);
        tt.show();
        return;
    }

    CharSequence paste = clip.getText();
    byte[] utf8;
    try {
        utf8 = paste.toString().getBytes("UTF-8");
    } catch (UnsupportedEncodingException e) {
        Log.e(TermDebug.LOG_TAG, "UTF-8 encoding not found.");
        return;
    }

    getCurrentTermSession().write(paste.toString());
}
 
開發者ID:dyne,項目名稱:ZShaolin,代碼行數:20,代碼來源:Term.java

示例3: swipeRight

import android.text.ClipboardManager; //導入方法依賴的package包/類
public void swipeRight() {
    if (LatinKeyboardView.DEBUG_AUTO_PLAY) {
        ClipboardManager cm = ((ClipboardManager)getSystemService(CLIPBOARD_SERVICE));
        CharSequence text = cm.getText();
        if (!TextUtils.isEmpty(text)) {
            mKeyboardSwitcher.getInputView().startPlaying(text.toString());
        }
    }
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:10,代碼來源:KP2AKeyboard.java

示例4: clipboardTextLength

import android.text.ClipboardManager; //導入方法依賴的package包/類
public static final int clipboardTextLength(Context context) {
	ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
	CharSequence text = cm != null ? cm.getText() : null;
	return text != null ? text.length() : 0;
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:6,代碼來源:ClipboardUtil.java

示例5: doSwipeAction

import android.text.ClipboardManager; //導入方法依賴的package包/類
private boolean doSwipeAction(String action) {
    //Log.i(TAG, "doSwipeAction + " + action);
    if (action == null || action.equals("") || action.equals("none")) {
        return false;
    } else if (action.equals("close")) {
        handleClose();
    } else if (action.equals("settings")) {
        launchSettings();
    } else if (action.equals("suggestions")) {
        if (mSuggestionForceOn) {
            mSuggestionForceOn = false;
            mSuggestionForceOff = true;
        } else if (mSuggestionForceOff) {
            mSuggestionForceOn = true;
            mSuggestionForceOff = false;                
        } else if (isPredictionWanted()) {
            mSuggestionForceOff = true;
        } else {
            mSuggestionForceOn = true;
        }
        setCandidatesViewShown(isPredictionOn());
    } else if (action.equals("lang_prev")) {
        toggleLanguage(false, false);
    } else if (action.equals("lang_next")) {
        toggleLanguage(false, true);
    } else if (action.equals("debug_auto_play")) {
        if (LatinKeyboardView.DEBUG_AUTO_PLAY) {
            ClipboardManager cm = ((ClipboardManager) getSystemService(CLIPBOARD_SERVICE));
            CharSequence text = cm.getText();
            if (!TextUtils.isEmpty(text)) {
                mKeyboardSwitcher.getInputView().startPlaying(text.toString());
            }
        }
    } else if (action.equals("full_mode")) {
        if (isPortrait()) {
            mKeyboardModeOverridePortrait = (mKeyboardModeOverridePortrait + 1) % mNumKeyboardModes;
        } else {
            mKeyboardModeOverrideLandscape = (mKeyboardModeOverrideLandscape + 1) % mNumKeyboardModes;
        }
        toggleLanguage(true, true);
    } else if (action.equals("extension")) {
        sKeyboardSettings.useExtension = !sKeyboardSettings.useExtension;
        reloadKeyboards();
    } else if (action.equals("height_up")) {
        if (isPortrait()) {
            mHeightPortrait += 5;
            if (mHeightPortrait > 70) mHeightPortrait = 70;
        } else {
            mHeightLandscape += 5;
            if (mHeightLandscape > 70) mHeightLandscape = 70;                
        }
        toggleLanguage(true, true);
    } else if (action.equals("height_down")) {
        if (isPortrait()) {
            mHeightPortrait -= 5;
            if (mHeightPortrait < 15) mHeightPortrait = 15;
        } else {
            mHeightLandscape -= 5;
            if (mHeightLandscape < 15) mHeightLandscape = 15;                
        }
        toggleLanguage(true, true);
    } else {
        Log.i(TAG, "Unsupported swipe action config: " + action);
    }
    return true;
}
 
開發者ID:klausw,項目名稱:hackerskeyboard,代碼行數:67,代碼來源:LatinIME.java

示例6: clipboardTextLength

import android.text.ClipboardManager; //導入方法依賴的package包/類
public static final int clipboardTextLength(Context context) {
    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    CharSequence text = cm != null ? cm.getText() : null;
    return text != null ? text.length() : 0;
}
 
開發者ID:netease-im,項目名稱:NIM_Android_UIKit,代碼行數:6,代碼來源:ClipboardUtil.java

示例7: getClipText

import android.text.ClipboardManager; //導入方法依賴的package包/類
private CharSequence getClipText() {
	ClipboardManager clipboard = (ClipboardManager) getContext()
			.getSystemService(Context.CLIPBOARD_SERVICE);
	return clipboard.getText();
}
 
開發者ID:cybro,項目名稱:PalmCalc,代碼行數:6,代碼來源:CalculatorEditText.java

示例8: onCreate

import android.text.ClipboardManager; //導入方法依賴的package包/類
@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_qr);
      
      ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build();
      imgLoader = ImageLoader.getInstance();
      imgLoader.init(config);
      
      qrImg = (ImageView)findViewById(R.id.qrImg);
      qrTxt = (TextView)findViewById(R.id.qrTxt);
      

      
clipboard = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);



      /*
       * clipboard.getText() is now deprecated. But I am going to use it here
       * because the new way of doing the same thing only works on API lvl 11+
       * Since I want this application to support API lvl 4+ we have to use
       * the old method.
       */
CharSequence clipTxt = clipboard.getText();

//This is the new, non-deprecated way of getting text from the Clipboard.
//CharSequence clipTxt = clipboard.getPrimaryClip().getItemAt(0).getText();
      
      
      //If the clipboard has text, and it is more than 0 characters.
      if((null != clipTxt) && (clipTxt.length() > 0)){
      	try {
      		qrTxt.setText(clipTxt);
      		copiedStr = clipTxt.toString();
		fullUrl += URLEncoder.encode(copiedStr, "UTF-8");
		imgLoader.displayImage(fullUrl, qrImg);
		
	} catch (UnsupportedEncodingException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
      	
      }else{ //If no text display a dialog.
      	AlertDialog.Builder builder = new AlertDialog.Builder(this);
      	
      	builder.setTitle("QRMaker")
      	.setCancelable(true)
      	.setMessage("There was no data in the clipboard! Go copy something and come back")
      	.setIcon(R.drawable.nuke)
      	.setNeutralButton("Okay", new OnClickListener() {

		@Override
		public void onClick(DialogInterface arg0, int arg1) {
			finish();
			
		}

      	});
      	
      	AlertDialog diag = builder.create();
      	diag.show();
      }
  }
 
開發者ID:FoamyGuy,項目名稱:QRMaker,代碼行數:65,代碼來源:QRActivity.java


注:本文中的android.text.ClipboardManager.getText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。