本文整理汇总了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);
}
示例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());
}
示例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());
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例7: getClipText
import android.text.ClipboardManager; //导入方法依赖的package包/类
private CharSequence getClipText() {
ClipboardManager clipboard = (ClipboardManager) getContext()
.getSystemService(Context.CLIPBOARD_SERVICE);
return clipboard.getText();
}
示例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();
}
}