本文整理匯總了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();
}
}