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.
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.
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();