微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ContentResolver.query() 方法抛出“无效的令牌限制”错误

如何解决ContentResolver.query() 方法抛出“无效的令牌限制”错误

在版本号为 RQ1A.201205.003 或更高版本的 Pixel 设备上发生以下错误
我想知道错误的原因以及如何处理。
这是错误还是规范更改?

代码

      ContentResolver resolver = getContentResolver();
      String order = "date ASC limit 100";
      Cursor cursor = resolver.query(
          CallLog.Calls.CONTENT_URI,null,order);

错误

"Invalid token limit,LINE:142,Method:readExceptionFromParcel Exception:Invalid token limit"

■发生错误的版本号

https://support.google.com/pixelphone/thread/87641266
・RQ1A.201205.003
・RQ1A.201205.008
・RQ1A.201205.011

https://support.google.com/pixelphone/thread/93232095
・RQ1A.210105.002
・RQ1A.210105.003

https://support.google.com/pixelphone/thread/96244000
・RQ1A.210205.004

■如果换成下面的代码,就不会出错。

buildUpon().appendQueryParameter("limit","100")

■附加信息 使用官方文档方法实现时,没有出现错误,但是LIMIT子句不起作用(检索到所有记录)。

ContentProvider - query

 // Request 20 records starting at row index 30.
 Bundle queryArgs = new Bundle();
 queryArgs.putInt(ContentResolver.QUERY_ARG_OFFSET,30);
 queryArgs.putInt(ContentResolver.QUERY_ARG_LIMIT,20);
 
 Cursor cursor = getContentResolver().query(
       contentUri,// Content Uri is specific to individual content providers.
       projection,// String[] describing which columns to return.
       queryArgs,// Query arguments.
       null);         // Cancellation signal.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。