当前位置: 首页>>代码示例>>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;未经允许,请勿转载。