Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

156
Visualizações
How do I paste text with Android clipboard manager in an empty input in a WebView?

We have a web page with an input element on a webview App on Android.

If the input text is not empty, has text, you can touch and the clipboard manager is launched and shows:

  • When clipboard is empty "select all"
  • When clipboard is full "paste, select all"

BUT, when the input text is empty you can not launch the clipboard manager in order to paste text.

Should I implement onLongClick on Android webview app? if yes, what is the code to simply launch the Android Clipboard Manager?

Should I add an html paste button and solve it with html code?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This is the best solution I have found, just get the text of the clipboard and paste it throug javascript when longclick is done in a focused input of a web page loaded in myWebView

myWebView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
                ClipData clip;
                clip = clipboard.getPrimaryClip();
                String str = clip.getItemAt(0).getText().toString();
                myWebView.evaluateJavascript("try{document.activeElement.value='"+str+"';}catch(e){}", new ValueCallback<String>() {
                    @Override
                    public void onReceiveValue(String s) {}
                });
                return true;
            }
        });
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda