遇到Android N的第一个小坑

Google 2016 I/O大会正如火如荼,正好这两天拿到一部工程机,就测试一下现有的应用在Android N (Preview 1)上的表现。一上发现框架部份出问题,整个应用无法正常启动。

Debug跟踪了一会,发现问题竟然出在Cursor.getBlog这个接口上。如下是Android M(6.0.1_r10)的源码:


/**    * Returns the value of the requested column as a byte array.    *    *

The result and whether this method throws an exception when the

* column value is null or the column type is not a blob type is

* implementation-defined.

*

* @param columnIndex the zero-based index of the target column.

* @return the value of that column as a byte array.

*/

byte[] getBlob(int columnIndex);

在前面的版本如果数据表中这项值没有赋值的话,getBlob是会返回null的。之前我们的代码要根据这个值为null或者返回的byte[]长度为0时重新获取一次数据,而这次在Android N的手机上发现,数据表中这一项没有赋值的话,getBlob会返回长度为1的默认byte[](byte[0]的值为0),从而导致后面重新获取数据的逻辑一直不被执行。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容