当前位置: 首页>>代码示例>>Java>>正文


Java ClipboardManager.hasPrimaryClip方法代码示例

本文整理汇总了Java中android.content.ClipboardManager.hasPrimaryClip方法的典型用法代码示例。如果您正苦于以下问题:Java ClipboardManager.hasPrimaryClip方法的具体用法?Java ClipboardManager.hasPrimaryClip怎么用?Java ClipboardManager.hasPrimaryClip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.ClipboardManager的用法示例。


在下文中一共展示了ClipboardManager.hasPrimaryClip方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: performClipboardCheck

import android.content.ClipboardManager; //导入方法依赖的package包/类
private void performClipboardCheck() {
    Log.d("clip", "clip_changed");
    if (!Settings.getInstance(MyApplication.getContext()).getMoniteClipboardQ()) {
        return;
    }
    ClipboardManager cb = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    if (cb.hasPrimaryClip()) {
        if (cb.hasText()) {
            String text = cb.getText().toString();
            if (/*isEnglish(text)*/true) {
                long[] vibList = new long[1];
                vibList[0] = 10L;
                Intent intent = new Intent(getApplicationContext(), PopupActivity.class);
                intent.setAction(Intent.ACTION_SEND);
                intent.setType("text/plain");
                //intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                intent.putExtra(Intent.EXTRA_TEXT, text);
                startActivity(intent);
            }
        }
    }
}
 
开发者ID:mmjang,项目名称:quiz_helper,代码行数:25,代码来源:CBWatcherService.java

示例2: loadFromClipboard

import android.content.ClipboardManager; //导入方法依赖的package包/类
public String loadFromClipboard(Context context) {
    ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE);
    if (clipboardManager.hasPrimaryClip() == false) {
        return null;
    }

    ClipData clipData = clipboardManager.getPrimaryClip();
    ClipData.Item item = null;
    if (clipData.getItemCount() >= 1) {
        item = clipData.getItemAt(0);
    }

    if (item == null || item.getText() == null) {
        return null;
    }

    String clipText = (String) item.getText().toString();
    if (TextUtils.isEmpty(clipText)) {
        return null;
    }


    return clipText;
}
 
开发者ID:monthlypub,项目名称:SmingZZick_App,代码行数:25,代码来源:AttackManager.java

示例3: pasteText

import android.content.ClipboardManager; //导入方法依赖的package包/类
public void pasteText(View view) {

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

        if(clipboardManager.hasPrimaryClip()&&clipboardManager.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)){
            ClipData.Item item=clipboardManager.getPrimaryClip().getItemAt(0);
            et.setText(item.getText());
        }
        else{
            Toast.makeText(this, R.string.secret_toast_cantFindTextInCB,Toast.LENGTH_LONG).show();
        }


    }
 
开发者ID:youben11,项目名称:cryptili,代码行数:15,代码来源:SecretActivity.java

示例4: getTextFromClipboar

import android.content.ClipboardManager; //导入方法依赖的package包/类
/**
 * 从剪切板获取文本
 *
 * @return   切板获取文本 ,未获取到时返回""
 */
public static String getTextFromClipboar() {
    ClipboardManager clipboardManager = (ClipboardManager) UtilManager.getContext()
            .getSystemService(Context.CLIPBOARD_SERVICE);
    if (clipboardManager.hasPrimaryClip()) {
        return clipboardManager.getPrimaryClip().getItemAt(0).getText().toString();
    }
    return "";
}
 
开发者ID:sundevin,项目名称:utilsLibrary,代码行数:14,代码来源:ClipboardUtils.java

示例5: pasteFromClip

import android.content.ClipboardManager; //导入方法依赖的package包/类
private void pasteFromClip()
{
    ClipboardManager clipboard = (ClipboardManager) getSystemService(this.CLIPBOARD_SERVICE);

    if(clipboard.hasPrimaryClip())
    {
        inputText = clipboard.getPrimaryClip().getItemAt(0).getText().toString(); //copy whats inside primary clipboard to input text
        inputText = inputText.toLowerCase();
        inputTextView.setText(inputText.toLowerCase());
    }

    else
        framework.system_message_small("Error: Clipboard is empty");
}
 
开发者ID:FYP17-4G,项目名称:Aardvark,代码行数:15,代码来源:GUI_Enc_Dec.java

示例6: onPrepareOptionsMenu

import android.content.ClipboardManager; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    // The paste menu item is enabled if there is data on the clipboard.
    ClipboardManager clipboard = (ClipboardManager)
            getSystemService(Context.CLIPBOARD_SERVICE);


    MenuItem mPasteItem = menu.findItem(R.id.menu_paste);

    // If the clipboard contains an item, enables the Paste option on the menu.
    if (clipboard.hasPrimaryClip()) {
        mPasteItem.setEnabled(true);
    } else {
        // If the clipboard is empty, disables the menu's Paste option.
        mPasteItem.setEnabled(false);
    }

    // Gets the number of notes currently being displayed.
    final boolean haveItems = getListAdapter().getCount() > 0;

    // If there are any notes in the list (which implies that one of
    // them is selected), then we need to generate the actions that
    // can be performed on the current selection.  This will be a combination
    // of our own specific actions along with any extensions that can be
    // found.
    if (haveItems) {

        // This is the selected item.
        Uri uri = ContentUris.withAppendedId(getIntent().getData(), getSelectedItemId());

        // Creates an array of Intents with one element. This will be used to send an Intent
        // based on the selected menu item.
        Intent[] specifics = new Intent[1];

        // Sets the Intent in the array to be an EDIT action on the URI of the selected note.
        specifics[0] = new Intent(Intent.ACTION_EDIT, uri);

        // Creates an array of menu items with one element. This will contain the EDIT option.
        MenuItem[] items = new MenuItem[1];

        // Creates an Intent with no specific action, using the URI of the selected note.
        Intent intent = new Intent(null, uri);

        /* Adds the category ALTERNATIVE to the Intent, with the note ID URI as its
         * data. This prepares the Intent as a place to group alternative options in the
         * menu.
         */
        intent.addCategory(Intent.CATEGORY_ALTERNATIVE);

        /*
         * Add alternatives to the menu
         */
        menu.addIntentOptions(
            Menu.CATEGORY_ALTERNATIVE,  // Add the Intents as options in the alternatives group.
            Menu.NONE,                  // A unique item ID is not required.
            Menu.NONE,                  // The alternatives don't need to be in order.
            null,                       // The caller's name is not excluded from the group.
            specifics,                  // These specific options must appear first.
            intent,                     // These Intent objects map to the options in specifics.
            Menu.NONE,                  // No flags are required.
            items                       // The menu items generated from the specifics-to-
                                        // Intents mapping
        );
            // If the Edit menu item exists, adds shortcuts for it.
            if (items[0] != null) {

                // Sets the Edit menu item shortcut to numeric "1", letter "e"
                items[0].setShortcut('1', 'e');
            }
        } else {
            // If the list is empty, removes any existing alternative actions from the menu
            menu.removeGroup(Menu.CATEGORY_ALTERNATIVE);
        }

    // Displays the menu
    return true;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:80,代码来源:NotesList.java


注:本文中的android.content.ClipboardManager.hasPrimaryClip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。