requestCode = intent.getStringExtra("requestCode");
一般写成if("055".equals(requestCode)){
prodId = intent.getStringExtra("prodId");prodName = intent.getStringExtra("prodName");
webOnlineBean.productId = prodId;/*"prod.100000"*/;
webOnlineBean.productName = prodName;/*"测试";*/
}
而不是f("requestCode".equals(055)){
prodId = intent.getStringExtra("prodId");
prodName = intent.getStringExtra("prodName");
webOnlineBean.productId = prodId;/*"prod.100000"*/;
webOnlineBean.productName = prodName;/*"测试";*/
}
好处:避免requestCode为空值时,报空指针错误;
本文讨论了在Android开发中如何通过合理使用条件语句来避免空指针异常,重点介绍了requestCode的检查和参数获取的最佳实践。
501

被折叠的 条评论
为什么被折叠?



