Code example for ClipboardManager

Methods: getPrimaryCliphasPrimaryClip

    	protected Void doInBackground(Void... nothing){
    		Log.i(TAG, "Clipboard Monitor Background running");
    		ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
	    	if (clipboard.hasPrimaryClip()){	//Check that clipboard is not empty
	    		ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);	//Get item zero
	    		text =  item.getText();
	    		//Save to database 
	    	return null; 
    	protected void onPostExecute(Void nothing){
    		Context context = getApplicationContext();
			CharSequence toastText = getString(R.string.stuff_copied);
			int duration = Toast.LENGTH_SHORT;
Stop searching for code, let great code find you!  Add Codota to your java IDE