1

I recently released a widget that reads data from a content provider. It seemed to work fine in testing, but I've received a number of crash reports related to permissions for the content provider.

This is the error I'm getting from the crash reports:

java.lang.SecurityException: Permission Denial: reading com.anydo.providers.TasksContentProvider uri content://com.anydo.provider/tasks from pid=24036, uid=10142 requires com.anydo.provider.permission.READ_ANYDO_TASKS, or grantUriPermission()

And from what I can see from different questions this might be related to the manifest file, so here's that:

<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="17" />

<uses-permission android:name="com.anydo.provider.permission.READ_ANYDO_TASKS" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <receiver android:name="AnydoWidgetProvider" >
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
        </intent-filter>

        <meta-data
            android:name="android.appwidget.provider"
            android:resource="@xml/anydo_widget_provider" />
    </receiver>

    <activity 
        android:name="com.gongchangstudio.minimalanydowidget.WidgetSettings" 
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
        </intent-filter>
    </activity>
     <service android:name="com.gongchangstudio.minimalanydowidget.TaskWidgetService"
        android:permission="android.permission.BIND_REMOTEVIEWS"
        android:exported="false" />

</application>

Any ideas?

Luke Hansford
  • 565
  • 1
  • 8
  • 24

1 Answers1

0

Found the answer elsewhere on Stack Overflow - Android Permission denial in Widget RemoteViewsFactory for Content

I guess that it had something to do with the permission running on the same thread as something else, because adding the following code to onDataSetChanged() solved the problem.

Thread thread = new Thread() {
    public void run() {
        query();
    }
};
thread.start();
try {
    thread.join();
} catch (InterruptedException e) {
}
Community
  • 1
  • 1
Luke Hansford
  • 565
  • 1
  • 8
  • 24
  • 1
    Sorry but this is only a workaround; for a solution, see [Jeff's answer](http://stackoverflow.com/a/20645908/2420519) of that question. – Hai Zhang Aug 05 '14 at 06:46