Skip to content

Instantly share code, notes, and snippets.

@f2prateek
Created August 8, 2012 05:26
Show Gist options
  • Save f2prateek/3292388 to your computer and use it in GitHub Desktop.
Save f2prateek/3292388 to your computer and use it in GitHub Desktop.
Clipboard Share
package com.aokp.romcontrol;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import com.aokp.romcontrol.R;
public class ShareToClipboard extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// get the clipboard system service
ClipboardManager mClipboardManager = (ClipboardManager) this.getSystemService(CLIPBOARD_SERVICE);
// get the intent
Intent intent = getIntent();
// get the text
CharSequence text = intent.getCharSequenceExtra(Intent.EXTRA_TEXT);
// put the text on the clipboard
mClipboardManager.setPrimaryClip(ClipData.newPlainText("Shared to RC", text));
// alert the user
Toast.makeText(this, R.string.clipboard_notification, Toast.LENGTH_SHORT).show();
finish();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment