Ejemplo n.º 1
0
 void copyIntent() {
   ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
   Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
   ClipData clip = ClipData.newIntent("intent", intent);
   cm.setPrimaryClip(clip);
   Toast.makeText(this, "Intent Copied", 0).show();
 }
 /**
  * Populate an intent object with the results gathered from remote input. This method should only
  * be called by remote input collection services when sending results to a pending intent.
  *
  * @param remoteInputs The remote inputs for which results are being provided
  * @param intent The intent to add remote inputs to. The {@link ClipData} field of the intent will
  *     be modified to contain the results.
  * @param results A bundle holding the remote input results. This bundle should be populated with
  *     keys matching the result keys specified in {@code remoteInputs} with values being the
  *     result per key.
  */
 public static void addResultsToIntent(RemoteInput[] remoteInputs, Intent intent, Bundle results) {
   Bundle resultsBundle = new Bundle();
   for (RemoteInput remoteInput : remoteInputs) {
     Object result = results.get(remoteInput.getResultKey());
     if (result instanceof CharSequence) {
       resultsBundle.putCharSequence(remoteInput.getResultKey(), (CharSequence) result);
     }
   }
   Intent clipIntent = new Intent();
   clipIntent.putExtra(EXTRA_RESULTS_DATA, resultsBundle);
   intent.setClipData(ClipData.newIntent(RESULTS_CLIP_LABEL, clipIntent));
 }
 /**
  * 复制意图到剪贴板
  *
  * @param context 上下文
  * @param intent 意图
  */
 public static void copyIntent(Context context, Intent intent) {
   ClipboardManager clipboard =
       (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
   clipboard.setPrimaryClip(ClipData.newIntent("intent", intent));
 }