Return a Result from a an Activity

   

The ResultActivity launches the GetterActivity and sends a prompt string to it. The GetterActivity returns an integer value to the ResultActivity. It also returns a result code, hopefully Activity.RESULT_OK, to the ResultActivity. Should we think of the ResultActivity as a client and the GetterActivity as a server?

The ResultActivity calls startActivityForResult (twice) instead of the startActivity we saw here. The GetterActivity calls setResult.

Underline

A SpannableString is a string whose substrings can be decorated with underlining, strike-through, foreground color etc.

Source code in Result.zip

  1. ResultActivity.java
  2. main.xml: monospace typeface to right-justify the numbers. I hope we never see the “Did not receive” message.
  3. GetterActivity.java
  4. getter.xml: a horizontal LinearLayout inside a vertical one. Note the EditText’s layout_width and layout_weight.
  5. AndroidManifest.xml has a second activity element.