Android 中的 URI 匹配器问题
我有一个权限字符串定义如下:
public final static String AUTHORITY = "dsndata.sds2mobile.jobprovider";
后面是 UriMatcher 的版本:
uriMatcher.addURI(JobMetaData.AUTHORITY, "/JobNames/*",
JOBNAME_SINGLE_URI);
传递到交换机的 uri 是:
content://dsndata.sds2mobile.jobprovider/JobNames/test
这会通过交换机并达到默认值(抛出 IllegalArgumentException)。
我错过了什么吗?我进行了搜索,但找不到任何可以解释不匹配的原因。
I have an authority string defined as such:
public final static String AUTHORITY = "dsndata.sds2mobile.jobprovider";
Followed by an edition to the UriMatcher:
uriMatcher.addURI(JobMetaData.AUTHORITY, "/JobNames/*",
JOBNAME_SINGLE_URI);
The uri that gets passed to the switch is:
content://dsndata.sds2mobile.jobprovider/JobNames/test
This falls through the switch and hits the default (which throws an IllegalArgumentException).
Am I missing something? I've searched and can't find anything that would account for the mismatch.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我对 IllegalArgumentException 也遇到了同样的问题。即使那些调试 Uri 的人也是一样的! [让我发疯]。如果您首先定义了 */ match ,那么它似乎会匹配并阻止其他人匹配。 订单很重要!!
我重新订购了,“external_warning_id”现在工作正常。
I had the same problem too with IllegalArgumentException. Even those have debugging the Uri's were the same! [drove me crazy]. If you have defined */ match first that seems to match and prevent others from matching. ORDER IS IMPORTANT!!
I reordered and the 'external_warning_id' now works fine.
尝试删除前导斜杠:
而不是
(更新)
使用提供的代码,我通过将该行移动到顶部来使其工作。定义的顺序很重要,似乎您的其他一些匹配器在某种程度上发生了冲突。不管怎样,把它移到顶部是有效的。
Try removing the leading slash:
instead of
(Update)
With the code supplied, I got it working by moving that line to the top. The order of definition is important and it seems some of your other matchers somehow conflict. Anyway, moving it to the top worked.