我正在尝试在我的代码中使用putExtra(String,String)
来传递null
。
正如该参数所示,第二个参数可以是null
,因为它是一个字符串,我可以发送它。
this.getIntent().putExtra(AppConstant.TestString, null);
当我使用上述代码时,它会给我一个错误提示: Intent 的 putExtra(String, String) 方法对于类型 Intent 来说是有歧义的。 然而,它允许我使用:
this.getIntent().putExtra(AppConstant.TestString, "");
请帮我解释一下这个问题,提前感谢。
boolean
默认为false
,而int
默认为0,而不是null。对吗? - CodeWarriornull
时,它是不明确的。 - Apoorv