为什么要定义android活动result_ok -1 [英] why define android activity result_ok -1

查看:61
本文介绍了为什么要定义android活动result_ok -1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 /** Standard activity result: operation succeeded. */
    public static final int RESULT_OK           = -1;

为什么要在android活动中定义RESULT_OK -1,而不是1?

why define RESULT_OK -1 in android activity,not 1?

推荐答案

至于为什么选择"-1",则只能猜测.我最好的猜测是,Android试图确保RESULT_OK不会与用户定义的常量发生冲突.也就是说,当您开发活动并定义自己的响应代码时,您可能会选择正整数值.如果RESULT_OK为"1",则应用程序开发人员也有可能选择它.

As for why "-1" was chosen, one can only guess. My best guess is that Android is trying to ensure that RESULT_OK does not collide with user-defined constants. That is, when you develop an Activity and define your own response codes, you would likely chose positive integer values. If RESULT_OK was "1", then there is a higher probability that an app developer might chose that as well.

只是我的理论.

这篇关于为什么要定义android活动result_ok -1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆