Search code examples
javaandroid-studioobject-type

What data type are Java things such as "RESULT_CANCELLED"


When invoking a sub-activity using startActivityForResult(), one uses the setResult() method, its first parameter being either RESULT_OK or RESULT_CANCELLED. I have seen other upper-case 'things' used as well. What are these 'things'? What data type are they? Is there a list somewhere? I've tried looking them up in various reference documents, with no success. Thanks for your help.


Solution

  • The first parameter of the Activity.setResult method is an int.

    Is there a list somewhere?

    No, because users can define their own result codes. Quoting the Activity javadoc:

    When an activity exits, it can call setResult(int) to return data back to its parent. It must always supply a result code, which can be the standard results RESULT_CANCELED, RESULT_OK, or any custom values starting at RESULT_FIRST_USER.