コード例 #1
0
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   String value = item.getIntent().getStringExtra(MENU_VALUE);
   switch (item.getItemId()) {
     case R.id.copy_ssid:
       {
         ClipboardManager clipboard =
             (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
         clipboard.setText(value);
         Toast.makeText(getActivity(), getString(R.string.msg_copied, value), Toast.LENGTH_SHORT)
             .show();
         return true;
       }
     case R.id.copy_mac:
       {
         ClipboardManager clipboard =
             (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
         clipboard.setText(value);
         Toast.makeText(getActivity(), getString(R.string.msg_copied, value), Toast.LENGTH_SHORT)
             .show();
         return true;
       }
     case R.id.use_mac:
       mCallbacks.onItemSelected(value);
       return true;
   }
   return super.onContextItemSelected(item);
 }
コード例 #2
0
ファイル: ServiceView.java プロジェクト: frankpi/Plugins
 @Override
 public void onClick(View v) {
   // TODO Auto-generated method stub
   switch (v.getId()) {
     case R.id.service_back:
       pluginManagerView.closePlugin();
       break;
     case R.id.service_copy_qq:
       // 从API11开始android推荐使用android.content.ClipboardManager
       // 为了兼容低版本我们这里使用旧版的android.text.ClipboardManager,虽然提示deprecated,但不影响使用。
       ClipboardManager cm =
           (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
       // 将文本内容放到系统剪贴板里。
       cm.setText(tvQQ.getText());
       Toast.makeText(getContext(), "复制成功,可以联系我们了。", Toast.LENGTH_LONG).show();
       break;
     case R.id.service_send:
       String url = "mqqwpa://im/chat?chat_type=wpa&uin=3508928085";
       Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
       intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
       PluginEntry.getTargetGame().startActivity(intent);
       break;
     default:
       break;
   }
 }
コード例 #3
0
 public void onClick() {
   @SuppressWarnings("deprecation")
   ClipboardManager clipboard =
       (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
   clipboard.setText(mRenderer.renderEventItem(getObject()).toString());
   Toast.makeText(getActivity(), R.string.text_copied, Toast.LENGTH_SHORT).show();
 }
コード例 #4
0
ファイル: EditText.java プロジェクト: KhalidElSayed/PixlUI
  @SuppressWarnings("deprecation")
  @SuppressLint("NewApi")
  /*
   * Cancel clipboard content
   */
  public void cancelClipBoardContent() {

    if (android.os.Build.VERSION.SDK_INT < 11) {
      android.text.ClipboardManager clipboard =
          (android.text.ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
      if (clipboard != null) {
        clipboard.setText("");
      }
    } else {
      android.content.ClipboardManager clipboard =
          (android.content.ClipboardManager)
              getContext().getSystemService(Context.CLIPBOARD_SERVICE);
      if (clipboard != null
          && clipboard.getPrimaryClip() != null
          && clipboard.getPrimaryClip().getItemCount() > 0) {
        android.content.ClipData clip = android.content.ClipData.newPlainText("", "");
        clipboard.setPrimaryClip(clip);
      }
    }
  }
コード例 #5
0
 @Override
 protected void onPostExecute(String ayah) {
   Activity activity = getActivity();
   if (ayah != null && activity != null) {
     ayah =
         "("
             + ayah
             + ")"
             + " "
             + "["
             + QuranInfo.getSuraName(activity, this.sura, true)
             + " : "
             + this.ayah
             + "]"
             + activity.getString(R.string.via_string);
     if (copy) {
       ClipboardManager cm =
           (ClipboardManager) activity.getSystemService(Activity.CLIPBOARD_SERVICE);
       cm.setText(ayah);
       Toast.makeText(
               activity, activity.getString(R.string.ayah_copied_popup), Toast.LENGTH_SHORT)
           .show();
     } else {
       final Intent intent = new Intent(Intent.ACTION_SEND);
       intent.setType("text/plain");
       intent.putExtra(Intent.EXTRA_TEXT, ayah);
       startActivity(Intent.createChooser(intent, activity.getString(R.string.share_ayah)));
     }
   }
   mCurrentTask = null;
 }
コード例 #6
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == android.R.id.home) {
     finish();
     overridePendingTransition(R.anim.fade_in, R.anim.slide_out_right);
     return true;
   } else if (item.getItemId() == R.id.action_browser) {
     Intent intent =
         new Intent(
             Intent.ACTION_VIEW,
             Uri.parse(
                 getIntent()
                     .getDataString()
                     .replace(getResources().getString(R.string.IMAGE_SCHEME), "http")));
     startActivity(intent);
     finish();
     return true;
   } else if (item.getItemId() == R.id.action_save) {
     DownloadManager d = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
     if (d != null) {
       DownloadManager.Request r =
           new DownloadManager.Request(
               Uri.parse(
                   getIntent()
                       .getDataString()
                       .replace(getResources().getString(R.string.IMAGE_SCHEME), "http")));
       if (Build.VERSION.SDK_INT >= 11) {
         r.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
         r.allowScanningByMediaScanner();
       }
       d.enqueue(r);
     }
     return true;
   } else if (item.getItemId() == R.id.action_copy) {
     if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
       android.text.ClipboardManager clipboard =
           (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
       clipboard.setText(
           getIntent()
               .getDataString()
               .replace(getResources().getString(R.string.IMAGE_SCHEME), "http"));
     } else {
       @SuppressLint("ServiceCast")
       android.content.ClipboardManager clipboard =
           (android.content.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
       android.content.ClipData clip =
           android.content.ClipData.newRawUri(
               "IRCCloud Image URL",
               Uri.parse(
                   getIntent()
                       .getDataString()
                       .replace(getResources().getString(R.string.IMAGE_SCHEME), "http")));
       clipboard.setPrimaryClip(clip);
     }
     Toast.makeText(ImageViewerActivity.this, "Link copied to clipboard", Toast.LENGTH_SHORT)
         .show();
   }
   return super.onOptionsItemSelected(item);
 }
コード例 #7
0
 public void copyHoroscopeToClipboard() {
   TextView textView = (TextView) findViewById(R.id.tvSagittariusToday);
   ClipboardManager clipboardManager =
       (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
   clipboardManager.setText(textView.getText());
   Toast toast = Toast.makeText(getApplicationContext(), "Successfully copied", 200);
   toast.setGravity(Gravity.CENTER, 0, 0);
   toast.show();
 }
コード例 #8
0
 private void processSelectionOption(int which, TLRPC.TL_messages_stickerSet stickerSet) {
   if (which == 0) {
     StickersQuery.removeStickersSet(
         getParentActivity(), stickerSet.set, (stickerSet.set.flags & 2) == 0 ? 1 : 2);
   } else if (which == 1) {
     StickersQuery.removeStickersSet(getParentActivity(), stickerSet.set, 0);
   } else if (which == 2) {
     try {
       Intent intent = new Intent(Intent.ACTION_SEND);
       intent.setType("text/plain");
       intent.putExtra(
           Intent.EXTRA_TEXT,
           String.format(
               Locale.US, "https://telegram.me/addstickers/%s", stickerSet.set.short_name));
       getParentActivity()
           .startActivityForResult(
               Intent.createChooser(
                   intent, LocaleController.getString("StickersShare", R.string.StickersShare)),
               500);
     } catch (Exception e) {
       FileLog.e("tmessages", e);
     }
   } else if (which == 3) {
     try {
       if (Build.VERSION.SDK_INT < 11) {
         android.text.ClipboardManager clipboard =
             (android.text.ClipboardManager)
                 ApplicationLoader.applicationContext.getSystemService(
                     Context.CLIPBOARD_SERVICE);
         clipboard.setText(
             String.format(
                 Locale.US, "https://telegram.me/addstickers/%s", stickerSet.set.short_name));
       } else {
         android.content.ClipboardManager clipboard =
             (android.content.ClipboardManager)
                 ApplicationLoader.applicationContext.getSystemService(
                     Context.CLIPBOARD_SERVICE);
         android.content.ClipData clip =
             android.content.ClipData.newPlainText(
                 "label",
                 String.format(
                     Locale.US,
                     "https://telegram.me/addstickers/%s",
                     stickerSet.set.short_name));
         clipboard.setPrimaryClip(clip);
       }
       Toast.makeText(
               getParentActivity(),
               LocaleController.getString("LinkCopied", R.string.LinkCopied),
               Toast.LENGTH_SHORT)
           .show();
     } catch (Exception e) {
       FileLog.e("tmessages", e);
     }
   }
 }
コード例 #9
0
 public static void setClipboardString(String string, Context context) {
   try {
     ClipboardManager clipboard =
         (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
     clipboard.setText(string);
   } catch (Exception e) {
     // Ingore
     // todo insert uncaught error handler
   }
 }
コード例 #10
0
 public static void clearClipboardString(Activity activity) {
   try {
     ClipboardManager clipboard =
         (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
     clipboard.setText("");
   } catch (Exception e) {
     // todo insert uncaught error handler
     // Ignore
   }
 }
コード例 #11
0
ファイル: OpenWeiChat.java プロジェクト: gg2787/GuoGuo
 public static void copy2Clipboard(String str2Copy, Context context) {
   if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
     android.content.ClipboardManager clipboardManager =
         (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
     clipboardManager.setText(str2Copy);
   } else {
     android.text.ClipboardManager clipboardManager =
         (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
     clipboardManager.setText(str2Copy);
   }
 }
コード例 #12
0
ファイル: Util.java プロジェクト: thedreadpirate/keepassdroid
  public static void copyToClipboard(Context context, String text)
      throws SamsungClipboardException {
    ClipboardManager clipboard =
        (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);

    try {
      clipboard.setText(text);
    } catch (NullPointerException e) {
      throw new SamsungClipboardException(e);
    }
  }
コード例 #13
0
  // Briefly show the contents of the barcode, then handle the result outside Barcode Scanner.
  private void handleDecodeExternally(Result rawResult, Bitmap barcode) {
    viewfinderView.drawResultBitmap(barcode);

    // Since this message will only be shown for a second, just tell the user what kind of
    // barcode was found (e.g. contact info) rather than the full contents, which they won't
    // have time to read.
    ResultHandler resultHandler = ResultHandlerFactory.makeResultHandler(this, rawResult);
    statusView.setText(getString(resultHandler.getDisplayTitle()));

    if (copyToClipboard) {
      ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
      clipboard.setText(resultHandler.getDisplayContents());
    }

    if (source == Source.NATIVE_APP_INTENT) {
      // Hand back whatever action they requested - this can be changed to Intents.Scan.ACTION when
      // the deprecated intent is retired.
      Intent intent = new Intent(getIntent().getAction());
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
      intent.putExtra(Intents.Scan.RESULT, rawResult.toString());
      intent.putExtra(Intents.Scan.RESULT_FORMAT, rawResult.getBarcodeFormat().toString());

      // crop barcode bitmap by 5pixels on each side
      barcode =
          Bitmap.createBitmap(barcode, 5, 5, barcode.getWidth() - 10, barcode.getHeight() - 10);

      ByteArrayOutputStream bitmapOutStream = new ByteArrayOutputStream();
      barcode.compress(Bitmap.CompressFormat.JPEG, 35, bitmapOutStream);
      intent.putExtra(Intents.Scan.RESULT_BITMAP_BYTES, bitmapOutStream.toByteArray());
      Message message = Message.obtain(handler, R.id.return_scan_result);
      message.obj = intent;
      handler.sendMessageDelayed(message, INTENT_RESULT_DURATION);
    } else if (source == Source.PRODUCT_SEARCH_LINK) {
      // Reformulate the URL which triggered us into a query, so that the request goes to the same
      // TLD as the scan URL.
      Message message = Message.obtain(handler, R.id.launch_product_query);
      int end = sourceUrl.lastIndexOf("/scan");
      message.obj =
          sourceUrl.substring(0, end)
              + "?q="
              + resultHandler.getDisplayContents().toString()
              + "&source=zxing";
      handler.sendMessageDelayed(message, INTENT_RESULT_DURATION);
    } else if (source == Source.ZXING_LINK) {
      // Replace each occurrence of RETURN_CODE_PLACEHOLDER in the returnUrlTemplate
      // with the scanned code. This allows both queries and REST-style URLs to work.
      Message message = Message.obtain(handler, R.id.launch_product_query);
      message.obj =
          returnUrlTemplate.replace(
              RETURN_CODE_PLACEHOLDER, resultHandler.getDisplayContents().toString());
      handler.sendMessageDelayed(message, INTENT_RESULT_DURATION);
    }
  }
コード例 #14
0
ファイル: CaptureActivity.java プロジェクト: daqing15/ard
  // Briefly show the contents of the barcode, then handle the result outside Barcode Scanner.
  private void handleDecodeExternally(
      Result rawResult, ResultHandler resultHandler, Bitmap barcode) {
    viewfinderView.drawResultBitmap(barcode);

    // Since this message will only be shown for a second, just tell the user what kind of
    // barcode was found (e.g. contact info) rather than the full contents, which they won't
    // have time to read.
    // TODO
    // TODO
    statusView.setText(getString(resultHandler.getDisplayTitle()));

    if (copyToClipboard && !resultHandler.areContentsSecure()) {
      ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
      clipboard.setText(resultHandler.getDisplayContents());
    }

    if (source == Source.NATIVE_APP_INTENT) {
      // Hand back whatever action they requested - this can be changed to Intents.Scan.ACTION when
      // the deprecated intent is retired.
      Intent intent = new Intent(getIntent().getAction());
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
      intent.putExtra(Intents.Scan.RESULT, rawResult.toString());
      intent.putExtra("RTN_CONTENT", resultHandler.getDisplayContents());
      intent.putExtra(Intents.Scan.RESULT_FORMAT, rawResult.getBarcodeFormat().toString());
      byte[] rawBytes = rawResult.getRawBytes();
      if (rawBytes != null && rawBytes.length > 0) {
        intent.putExtra(Intents.Scan.RESULT_BYTES, rawBytes);
      }
      Message message = Message.obtain(handler, R.id.return_scan_result);
      message.obj = intent;
      handler.sendMessageDelayed(message, INTENT_RESULT_DURATION);
    } else if (source == Source.PRODUCT_SEARCH_LINK) {
      // Reformulate the URL which triggered us into a query, so that the request goes to the same
      // TLD as the scan URL.
      Message message = Message.obtain(handler, R.id.launch_product_query);
      int end = sourceUrl.lastIndexOf("/scan");
      message.obj =
          sourceUrl.substring(0, end)
              + "?q="
              + resultHandler.getDisplayContents().toString()
              + "&source=zxing";
      handler.sendMessageDelayed(message, INTENT_RESULT_DURATION);
    } else if (source == Source.ZXING_LINK) {
      // Replace each occurrence of RETURN_CODE_PLACEHOLDER in the returnUrlTemplate
      // with the scanned code. This allows both queries and REST-style URLs to work.
      Message message = Message.obtain(handler, R.id.launch_product_query);
      message.obj =
          returnUrlTemplate.replace(
              RETURN_CODE_PLACEHOLDER, resultHandler.getDisplayContents().toString());
      handler.sendMessageDelayed(message, INTENT_RESULT_DURATION);
    }
  }
コード例 #15
0
ファイル: Info.java プロジェクト: mikeAopeneng/joyo-kanji
 /**
  * Copy debug information about the device to the clipboard
  *
  * @return debugInfo
  */
 public String copyDebugInfo() {
   StringBuilder sb = new StringBuilder();
   // KanjiDroid Version
   sb.append("KanjiDroid Version = ").append(VersionUtils.getPkgVersionName()).append("\n\n");
   // Android SDK
   sb.append("Android Version = " + Build.VERSION.RELEASE).append("\n\n");
   // ACRA install ID
   sb.append("ACRA UUID = ").append(Installation.id(this)).append("\n");
   String debugInfo = sb.toString();
   ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
   clipboard.setText(debugInfo);
   return debugInfo;
 }
コード例 #16
0
ファイル: Utils.java プロジェクト: HugoGresse/Anecdote
 /**
  * Copy given context to device clipboard
  *
  * @param context app context
  * @param title title/label of this clipboard
  * @param content text to be copied
  */
 public static void copyToClipboard(@NonNull Context context, String title, String content) {
   if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
     @SuppressWarnings("deprecation")
     android.text.ClipboardManager clipboard =
         (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
     clipboard.setText(content);
   } else {
     android.content.ClipboardManager clipboard =
         (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
     android.content.ClipData clip = android.content.ClipData.newPlainText(title, content);
     clipboard.setPrimaryClip(clip);
   }
 }
コード例 #17
0
 public void copyTextToClipboard(TextView txtView) {
   int sdk = android.os.Build.VERSION.SDK_INT;
   if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
     android.text.ClipboardManager clipboard =
         (android.text.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
     clipboard.setText(txtView.getText().toString());
   } else {
     android.content.ClipboardManager clipboard =
         (android.content.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
     android.content.ClipData clip =
         android.content.ClipData.newPlainText("text label", txtView.getText().toString());
     clipboard.setPrimaryClip(clip);
   }
 }
コード例 #18
0
ファイル: ChatWindow.java プロジェクト: nickvon/yaxim
 public boolean onContextItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.chat_contextmenu_copy_text:
       ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
       cm.setText(getMessageFromContextMenu(item));
       return true;
     case R.id.chat_contextmenu_resend:
       sendMessage(getMessageFromContextMenu(item).toString());
       Log.d(TAG, "resend!");
       return true;
     default:
       return super.onContextItemSelected((android.view.MenuItem) item);
   }
 }
コード例 #19
0
 @SuppressWarnings("deprecation")
 @SuppressLint("NewApi")
 protected void copyToClipboard() {
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
     ClipData data = ClipData.newPlainText("feed_text", mFeedItem.text);
     android.content.ClipboardManager mClipboard =
         (android.content.ClipboardManager)
             getContext().getSystemService(Context.CLIPBOARD_SERVICE);
     mClipboard.setPrimaryClip(data);
   } else {
     android.text.ClipboardManager mClipboard =
         (android.text.ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
     mClipboard.setText(mFeedItem.text);
   }
 }
コード例 #20
0
  @SuppressLint("NewApi")
  @SuppressWarnings("deprecation")
  public void copyToClipboard(String str) {
    if (android.os.Build.VERSION.SDK_INT < 11) {
      android.text.ClipboardManager clipboard =
          (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
      clipboard.setText(str);
    } else {
      android.content.ClipboardManager clipboard =
          (android.content.ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
      clipboard.setText(str);
    }

    Toast toast = Toast.makeText(this, R.string.text_copied_to_clipboard, Toast.LENGTH_SHORT);
    toast.show();
  }
コード例 #21
0
ファイル: LogViewer.java プロジェクト: Tody-Guo/qsysinfo
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    int pos = ((AdapterContextMenuInfo) item.getMenuInfo()).position;
    LogItem log = (LogItem) getListView().getItemAtPosition(pos);

    if (log != null && log.getMsg() != null) {
      ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);

      if (cm != null) {
        cm.setText(log.getMsg());

        Util.shortToast(this, R.string.copied_hint);
      }
    }

    return true;
  }
コード例 #22
0
  private void shareReflection() {
    Intent shareReflectionIntent = new Intent(Intent.ACTION_SEND);
    shareReflectionIntent.setType("text/plain");
    shareReflectionIntent.putExtra(Intent.EXTRA_TEXT, reflectionTitle.getText().toString());
    shareReflectionIntent.putExtra(Intent.EXTRA_TEXT, reflectionText.getText().toString());

    String clip = reflectionTitle.getText().toString();

    ClipboardManager clipBoard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    clipBoard.setText(
        clip); // Horrible workaround for sharing to Facebook. These lines of code copy the text to
               // clipboard, so that the user can manually paste his text after having chosen
               // Facebook from the chooser.

    startActivity(
        Intent.createChooser(shareReflectionIntent, getString(R.string.Share_reflection_label)));
  }
コード例 #23
0
ファイル: EnigmaApp.java プロジェクト: Jullianaa/startpad
  private void updateEncoding() {
    String code;

    try {
      machine.init(null);
      code = machine.encode(edit.getText().toString());
    } catch (Exception e) {
      output.setText("- error -");
      return;
    }

    if (fGroup) code = Enigma.groupLetters(code);

    output.setText(code);

    // Always copy results to clipboard
    cbm.setText(code);
  }
コード例 #24
0
  @Override
  public boolean onKeyShortcut(int keyCode, KeyEvent event) {
    switch (keyCode) {
      case KeyEvent.KEYCODE_C:
        MessageListItem view = (MessageListItem) getSelectedView();
        if (view == null) {
          break;
        }
        MessageItem item = view.getMessageItem();
        if (item != null && item.isSms()) {
          ClipboardManager clip =
              (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
          clip.setText(item.mBody);
          return true;
        }
        break;
    }

    return super.onKeyShortcut(keyCode, event);
  }
コード例 #25
0
 @SuppressWarnings("deprecation")
 public void copyID(View view) {
   Context context = getApplicationContext();
   int sdk = android.os.Build.VERSION.SDK_INT;
   if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
     android.text.ClipboardManager clipboard =
         (android.text.ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
     clipboard.setText(friendKey);
   } else {
     android.content.ClipboardManager clipboard =
         (android.content.ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
     android.content.ClipData clip = android.content.ClipData.newPlainText("friendKey", friendKey);
     clipboard.setPrimaryClip(clip);
   }
   Toast.makeText(
           context,
           context.getResources().getString(R.string.friend_profile_copied),
           Toast.LENGTH_SHORT)
       .show();
 }
コード例 #26
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    try {

      ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
      String text = getIntent().getStringExtra(Intent.EXTRA_TEXT);
      clipboard.setText(text);

      setResult(RESULT_OK);
      finish();

    } catch (Exception exception) {

      setResult(RESULT_CANCELED);
      finish();
    }
  }
コード例 #27
0
 @Override
 public void onClick(View v) {
   String strContent =
       String.valueOf(tv_recorded_appeal_taobao_code_url.getText())
           + String.valueOf(tv_recorded_appeal_taobao_code.getText());
   if (v.getId() == R.id.recorded_appeal_taobao_btn_copy) {
     clipboard.setText(strContent);
     btn_recorded_appeal_taobao_btn_copy.setEnabled(false);
     getHandlerContext().makeTextShort(getString(R.string.copy_success));
   } else if (v.getId() == R.id.recorded_appeal_taobao_btn_send_to_mobile) {
     Uri smsToUri = Uri.parse("smsto:");
     Intent mIntent = new Intent(android.content.Intent.ACTION_SENDTO, smsToUri);
     String strContent1 =
         "您申请的录音提取码为:"
             + strContent
             + " ,凭该提取码可在官网公开查询、下载本条通话录音,请妥善保管。客服电话:"
             + getString(R.string.app_phone)
             + "【"
             + getString(R.string.app_compayname)
             + "】";
     mIntent.putExtra("sms_body", strContent1);
     startActivity(mIntent);
   } else if (v.getId() == R.id.recorded_appeal_taobao_btn_cancel) {
     new AlertDialog.Builder(this)
         .setIcon(android.R.drawable.ic_dialog_info)
         .setMessage(R.string.undo_extraction_code_sure)
         .setPositiveButton(R.string.cancle, null)
         .setNeutralButton(
             R.string.sure,
             new DialogInterface.OnClickListener() {
               @Override
               public void onClick(DialogInterface dialog, int which) {
                 getDataTask(3);
               }
             })
         .show();
   } else {
     super.onClick(v);
   }
 }
コード例 #28
0
 // 处理网络请求返回的数据,并刷新UI
 @Override
 protected void onPostExecute(String result) {
   System.out.println("yzj onPostExecute" + result);
   if (result.equals("")) {
     //				textView.setText(null);
     return;
   }
   result = result.replace("<主人>", getResources().getString(R.string.app_master));
   if (result.contains("http:")) {
     input.setText("");
     textView.setText(result);
     String tempUrl = result.split("url\":\"")[1];
     System.out.println("yzj tempUrl = " + tempUrl);
     lastUrl = tempUrl;
     myWebView.loadUrl(lastUrl);
   }
   textView.setText(textView.getText().toString() + "\n" + result);
   ClipboardManager clipboard =
       (ClipboardManager) tempContext.getSystemService(Context.CLIPBOARD_SERVICE);
   clipboard.setText(result);
   super.onPostExecute(result);
 }
コード例 #29
0
 public final void setClipboardContent(String newText) {
   ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
   clipboard.setText(newText);
 }
 @Override
 public void setText(CharSequence text) {
   if (mClipboardManager != null) {
     mClipboardManager.setText(text);
   }
 }