Android的权限拒绝在窗口小部件RemoteViewsFactory的内容 [英] Android Permission denial in Widget RemoteViewsFactory for Content

查看:659
本文介绍了Android的权限拒绝在窗口小部件RemoteViewsFactory的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小部件,而我试图用来显示一个列表视图里面,从我的应用程序的本地数据库中的信息。

I have a widget which I am trying to use to display information from my app's local database inside of a listview.

我使用RemoteViewsService.RemoteViewsFactory接口加载我的名单中的内容。如果我跑了code的重新加载列表中onDataSetChanged方法块。该应用程序崩溃,并显示以下信息:

I'm using the RemoteViewsService.RemoteViewsFactory interface to load my list's contents. If I run the block of code which reloads the list in the onDataSetChanged method. the app crashes with the following message:

11-01 16:40:39.540:E / ACRA(27175):DataDisplay致命错误:权限被拒绝:读取com.datadisplay.content.ContentProviderAdapter URI内容://com.datadisplay.provider .internalDB由PID = 573,UID /事件= 10029要求提供出口,或grantUriPermission()

不过,在类的构造函数同样code运行工作得很好。当然,我需要这也工作在onDataSetChanged方法来更新之类的东西。

However, this same code run in the class's constructor works just fine. Of course, I need to have this also work in the onDataSetChanged method for updating and stuff.

下面是在清单中我的供应商的条目:

Here is my provider's entry in the manifest:

    <provider android:name="com.datadisplay.content.ContentProviderAdapter"
        android:authorities="com.datadisplay.provider.internalDB"
        android:exported="true"
        android:enabled="true"
        android:grantUriPermissions="true">
            <grant-uri-permission android:pathPattern="/events/"/>
    </provider>

我很喜欢的错误消息请求对出口的IT和授予乌里权限,但它仍然失败。我发现这个问题,这里的人有一个问题,但最终还是删除了自定义的权限和它的工作。我没有喜欢的任何自定义权限,但仍没有运气:

I am both exporting it AND granting Uri permissions like the error message requests, but it still fails. I found this question, where the guy had an issue but eventually removes his custom permissions and it worked. I don't have any custom permissions like that, but still no luck:

<一个href="http://stackoverflow.com/questions/9497270/widget-with-content-provider-impossible-to-use-readpermission">Widget与内容提供商;不可能用ReadPermission?

如果任何人有洞察力,我会非常感激,这是越来越令人难以置信的沮丧,哈哈。

If anyone has insight I'd be really grateful, this is getting incredibly frustrating, haha.

推荐答案

将这个在 onDataSetChanged()方法:

    Thread thread = new Thread() {
        public void run() {
            query();
        }
    };
    thread.start();
    try {
        thread.join();
    } catch (InterruptedException e) {
    }

从数据库读取里面的数据查询()方法。我不知道为什么取的数据在一个单独的线程可以帮助解决这个问题,但它的工程!我从Android的例子之一了这一点。

Fetch data from the database inside query() method. I do not know why fetching data in a separate thread helps get around this problem, but it works! I got this from one of the Android examples.

这篇关于Android的权限拒绝在窗口小部件RemoteViewsFactory的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆