コード例 #1
0
 private final void grantItemLocked(ClipData.Item item, String pkg) {
   if (item.getUri() != null) {
     grantUriLocked(item.getUri(), pkg);
   }
   Intent intent = item.getIntent();
   if (intent != null && intent.getData() != null) {
     grantUriLocked(intent.getData(), pkg);
   }
 }
コード例 #2
0
 private final void revokeItemLocked(ClipData.Item item) {
   if (item.getUri() != null) {
     revokeUriLocked(item.getUri());
   }
   Intent intent = item.getIntent();
   if (intent != null && intent.getData() != null) {
     revokeUriLocked(intent.getData());
   }
 }
コード例 #3
0
 private final void checkItemOwnerLocked(ClipData.Item item, int uid) {
   if (item.getUri() != null) {
     checkUriOwnerLocked(item.getUri(), uid);
   }
   Intent intent = item.getIntent();
   if (intent != null && intent.getData() != null) {
     checkUriOwnerLocked(intent.getData(), uid);
   }
 }
コード例 #4
0
  void pasteIntent() {
    ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    if (cm.hasPrimaryClip() == false) {
      Toast.makeText(this, "Clipboard Empty", 0).show();
      return;
    }
    if (cm.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT) == false) {
      Toast.makeText(this, "Clip is not intent", 0).show();
      return;
    }

    ClipData clip = cm.getPrimaryClip();
    ClipData.Item item = clip.getItemAt(0);
    Intent intent = item.getIntent();
    if (intent != null) {
      startActivity(intent);
    }
  }
コード例 #5
0
  /**
   * Return the content text. If there is intent in clip data, display intent, or display uri if uri
   * included, or html and text at last.
   *
   * @return the content in string.
   */
  public String getDiaplayText() {
    String ret = null;
    if (this.isCoerceText()) {
      ret = this.getContent();
    } else {
      ClipData.Item item = this.rawContent.getItemAt(0);
      CharSequence text = item.getText();
      String html = item.getHtmlText();
      Intent intent = item.getIntent();
      Uri uri = item.getUri();
      if (intent != null) {
        ret = intent.toUri(Intent.URI_INTENT_SCHEME);
      } else if (uri != null) {
        ret = uri.toString();
      } else if (html != null) {
        ret = html;
      } else if (text != null) {
        ret = text.toString();
      }
    }

    return ret;
  }