Will someone please explain RESULT_FIRST_USER

前端 未结 4 1034
甜味超标
甜味超标 2020-12-29 19:14

I don\'t understand the meaning, value, or importance of RESULT_FIRST_USER, other than that my own result codes must be greater than 1. Will someone please expl

4条回答
  •  盖世英雄少女心
    2020-12-29 19:58

    An activity result is a 32-bit integer. The possible values are divided into three ranges:

    • -2 and below: Unused.
    • -1 and 0: System-defined values. That is, activity results defined by Android.
    • 1 and above: User-defined values. That is, activity results defined by app developers.

    RESULT_FIRST_USER identifies the first value in the user-defined range. The following sample definitions show how system- and user-defined values fit together:

    public static final int RESULT_OK = -1; // Defined by Android. You don't write this code.
    public static final int RESULT_CANCELED = 0; // Defined by Android. You don't write this code.
    public static final int RESULT_ENDED_GAME = RESULT_FIRST_USER + 0; // Defined by an app.
    public static final int RESULT_ACTIVATED_RADAR = RESULT_FIRST_USER + 1; // Defined by an app.
    public static final int RESULT_LAUNCHED_ROCKETS = RESULT_FIRST_USER + 2; // Defined by an app.
    

提交回复
热议问题