1

Is there an equivalent for C's getch() in Android or Java? I want the execution to stop until the user does some action, like tap on the screen or maybe press one of the hardware buttons like volume control or whatever is available. Another option would be to show a modal message box window, which does not let the program continue until the user presses on OK. Is it possible to do this in a simple way in Android? What is the simplest way to get something equivalent to getch() function in android?

I need to be able to use this in a Thread as well

user13267
  • 6,871
  • 28
  • 80
  • 138

2 Answers2

1

There's no getch() equivalent function/method in java.

You must event handlers to do that.

Like having click handler for button,Which let you to some stuff on onClick() method,Once you click the button.

This example might helpful:Button Click Listeners in Android

Community
  • 1
  • 1
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
  • does that code show a dialogue box? Or create a command button of the type that we can specify in the xml? Does this block execution until the button is pressed? – user13267 Sep 02 '13 at 08:54
  • Yes exaclty.Untill unless you press the button,Code inside the block won't execute.That's is another matter that weather you are creating a dialog,or connection to internet..etc :) – Suresh Atta Sep 02 '13 at 08:55
1

There's an event listener for android like onCLickListener. Then you can also used Jdialog then set its .isEditable value to false like dialog.isEditable(false);

user2738939
  • 11
  • 1
  • 4