have an AppWidget with a Listview that I want to populate with a RemoteViewsService.RemoteViewsFactory.
I have the following error
E/AndroidRuntime(1203): java.lang.SecurityException: Permission Denial: reading com.crbin1.myapp.data.ProviderLTD uri content://com.crbin1.myapp.data.ProviderLTD/TB_WIDGET3P from pid=413, uid=10013 requires the provider be exported, or grantUriPermission()
If I export ProviderLTD (my content provider) in manifest it works, but I'd like to avoid to export it.
The other solution is grantUriPermission(). I set grantUriPermissions to true in manifest, but now I don't understand where in my code I have to grant the permissions.
public class Widget3pService extends RemoteViewsService {
@Override
public RemoteViewsFactory onGetViewFactory(Intent intent) {
return new StackRemoteViewsFactory(this.getApplicationContext(), intent);
}
}
class StackRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory {
private List<ObjW3Task> mWidgetItems = new ArrayList<ObjW3Task>();
private Context mContext;
private int mAppWidgetId;
public StackRemoteViewsFactory(Context context, Intent intent) {
mContext = context;
mAppWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
}
public RemoteViews getViewAt(int position) {
// use mWidgetItems to populate ListView
// fillInIntent for listeners
return myRemoteViews;
}
public void onDataSetChanged() {
mWidgetItems = new ArrayList<ObjW3Task>();
// create mWidgetItems by accessing my ContentProvider class
}
}