Tuesday, September 18, 2012

SL4A dialogCreateInput vs dialogGetInput

It should seem totally obvious but the main differences between these two are summarized below:

dialogCreateInput

  1. dialogCreateInput also requires dialogGetResponse to get the response inputted into the dialog box. The result attribute of dialogCreateInput is always None, and the actual response is in the result attribute of dialogGetResponse.
  2. dialogCreateInput lets you select the input type: "text", "number", etc. which will also determine the type of soft keyboard used. A number pad is shown for "numbers"
  3. dialogCreateInput does not have any buttons, so the user must use the back arrow or home key to escape if no code is used to dismiss the dialog. The obvious solution would be to use the return key.

dialogGetInput

  1. dialogGetInput returns the input in result attribute. the window
  2. dialogGetInput does not you select the type of input.
  3. dialogGetInput has OK and Cancel buttons to close
SL4A has a UI help page which mentions the difference between these two, but it still might not be immediately obvious. There is some detail under the heading: some notes right before the API references table.
In addition to the above functions, dialogGetInput and dialogGetPassword are convenience functions that create, display and return the relevant dialogs in one call.
There is only ever one instance of a dialog. Any dialogCreate call will cause the existing dialog to be destroyed.
Fork me on GitHub