Voice command that triggers a button in the Android application

-1

I'm a beginner on Android and made a framework for speech to text, I'd like to know how to trigger a button within the application using this function.

    
asked by anonymous 17.05.2017 / 02:36

1 answer

0

Hello, can you capture the right text? if not yet this tutorial exemplifies everything: link

If you have implemented similarly within the onActivityResult method, simply compare the return of the voice with the action and call the Runnable that was bound to the button.

EDITION

public class MainActivity extends Activity {
    private Button botaoAcao;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        botaoAcao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                acaoDoBotao().run();
            }
        });
    }

    private Runnable acaoDoBotao() {


        return new Runnable() {
            @Override
            public void run() {
                //acao do botao
            }
        };
    }

And within the onActivityResult to call the button just call acaoDoBotao().run();

    
17.05.2017 / 04:43