Java ClipboardManagerCompatFactory Example

Introduction

The java clipboardmanagercompatfactory example is extracted from the most popular open source projects, you can refer to the following example for usage.

Programming language: Java

Namespace/package name: jackpal.androidterm.emulatorview.compat

Example#1
File: Term.javaProject: ndukan/Android-Terminal-Emulator

 private boolean canPaste() {
   ClipboardManagerCompat clip = ClipboardManagerCompatFactory.getManager(getApplicationContext());
   if (clip.hasText()) {
     return true;
   }
   return false;
 }

Example#2
File: Term.javaProject: ndukan/Android-Terminal-Emulator

 private void doPaste() {
   if (!canPaste()) {
     return;
   }
   ClipboardManagerCompat clip = ClipboardManagerCompatFactory.getManager(getApplicationContext());
   CharSequence paste = clip.getText();
   byte[] utf8;
   try {
     utf8 = paste.toString().getBytes("UTF-8");
   } catch (UnsupportedEncodingException e) {
     Log.e(TermDebug.LOG_TAG, "UTF-8 encoding not found.");
     return;
   }
   getCurrentTermSession().write(paste.toString());
 }

Example#3
File: Term.javaProject: ndukan/Android-Terminal-Emulator

 private void doCopyAll() {
   ClipboardManagerCompat clip = ClipboardManagerCompatFactory.getManager(getApplicationContext());
   clip.setText(getCurrentTermSession().getTranscriptText().trim());
 }