title: Pass data to view through Accessibility service – Android
body: <p>I want to change text inside EditText within Accessibility service.
  My code is:</p>
  
  <pre><code>@Override
  public void onAccessibilityEvent(AccessibilityEvent event) {
  
      final AccessibilityNodeInfo source = event.getSource();
  if (source != null &amp; event.getClassName().equals("android.widget.EditText")) {
         AccessibilityNodeInfo currentSource = source;
  
          ClipboardManager clipboard = (ClipboardManager) this.getSystemService(Context.CLIPBOARD_SERVICE);
          ClipData clip = ClipData.newPlainText("label", "TestData");
          clipboard.setPrimaryClip(clip);
          currentSource.performAction(AccessibilityNodeInfo.ACTION_PASTE);
  </code></pre>
  
  <p>And it works well. When user presses on EditText it changes to "TestData". After that shows dialog with button. And I want to change text through pressing the button.</p>
  
  <pre><code> AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
          builder.setTitle("Test dialog");
          builder.setMessage("Content");
          builder.setPositiveButton("User", new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int whichButton) {
  
                  ClipboardManager clipboard = (ClipboardManager) getApplication().getSystemService(Context.CLIPBOARD_SERVICE);
                  ClipData clip = ClipData.newPlainText("label", "Test Username");
                  clipboard.setPrimaryClip(clip);
                  currentSource.performAction(AccessibilityNodeInfo.ACTION_PASTE);
                  dialog.dismiss();
              }
          });
  </code></pre>
  
  <p>Clipboard refreshes if press the button, but text inside EditText doesn't.</p>