Saturday, December 1, 2012

[android-developers] RemoteViewsService can't access ContentProvider in same app

I'm stepping through "Professional Android 4 Application
Development". I'm attempting to enter most of the code samples by
hand, but I'm deploying the provided downloaded apps if what I've
entered doesn't match what I expect.

I'm on chapter 14, the 3rd iteration of the "Earthquake" example,
which adds a list widget. The regular widget works fine, but when I
try to place the list widget on the homescreen, I get the following:

FATAL EXCEPTION: Binder Thread #2
java.lang.SecurityException: Permission Denial: reading
com.example.earthquake.EarthquakeProvider uri
content://com.example.earthquakeprovider/earthquakes from pid=806,
uid=10001 requires null
at android.content.ContentProvider
$Transport.enforceReadPermission(ContentProvider.java:295)
at android.content.ContentProvider
$Transport.query(ContentProvider.java:177)

When I install the corresponding app version from the code download,
it works fine. I must be missing a small detail, but I don't see it.
I've carefully compared the differences between the manifest files,
but I don't see anything that's obviously relevant.

If it matters, here is my entire app manifest. The only permission
entry relevant to the list widget is "BIND_REMOTEVIEWS", but the code
sample has the same thing.

-----------------------------------------
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.earthquake"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="14"
android:targetSdkVersion="15" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />

<application android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:theme="@style/AppTheme" >
<meta-data android:name="android.app.default_searchable"
android:value=".EarthquakeSearchResults" />

<uses-library android:name="com.google.android.maps" />

<activity android:name=".Earthquake" android:label="@string/
title_activity_earthquake"
android:uiOptions="splitActionBarWhenNarrow" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".PreferencesActivity"
android:label="@string/title_activity_preferences" />
<activity android:name=".FragmentPreferences" />
<activity android:name=".EarthquakeSearchResults"
android:exported="false" android:label="@string/search_description"
android:launchMode="singleTop" >
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category
android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<provider android:name=".EarthquakeProvider"
android:authorities="com.example.earthquakeprovider"
android:exported="false" />
<service android:name=".EarthquakeUpdateService"
android:enabled="true" />
<receiver android:name=".EarthquakeAlarmReceiver"
android:exported="false" >
<intent-filter>
<action
android:name="com.example.earthquake.ACTION_REFRESH_EARTHQUAKE_ALARM" /
>
</intent-filter>
</receiver>
<receiver android:name=".EarthquakeWidget"
android:label="Earthquake" >
<intent-filter>
<action
android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<intent-filter>
<action
android:name="com.example.earthquake.QUAKES_REFRESHED" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/quake_widget_info" />
</receiver>
<receiver android:name=".EarthquakeListWidget"
android:label="Earthquake List" >
<intent-filter>
<action
android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/quake_list_widget_info" />
</receiver>
<service android:name=".EarthquakeRemoteViewsService"
android:permission="android.permission.BIND_REMOTEVIEWS"/>
</application>
</manifest>
-------------------------

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate