Code example for ClipboardManager

Methods: addPrimaryClipChangedListener

0
	public void onCreate() { 
		super.onCreate(); 
		currentSelectedString = DEFAULT_STRING;
		createNotif(currentSelectedString);
		clipBoard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE);
		clipBoard.addPrimaryClipChangedListener(new ClipboardListener());
	} 
	 
	@Override 
	public int onStartCommand(Intent intent, int flags, int startId) {
		handleCommand(intent);
		return super.onStartCommand(intent, flags, startId);
	} 
	 
	private void handleCommand(Intent intent) {
		int command = intent.getIntExtra(INTENT_COMMAND_TYPE, INTENT_COMMAND_TYPE_USE);
		switch (command) {
		case INTENT_COMMAND_TYPE_PREVIOUS:
			createNotif(currentSelectedString = getStringInDirection(-1));
			break; 
Contextual code suggestions in your IDE  Get Codota for Java