には、RemoteViewsService.RemoteViewsFactoryを設定したいListViewを持つAppWidgetがあります。RemoteViewsFactory grantUriPermissionデータを取得する
私は、次のエラー
E/AndroidRuntime(1203)持っている:java.lang.SecurityException:許可 拒否:読んcom.crbin1.myapp.data.ProviderLTD URI 内容:// COMを。 PID = 413からcrbin1.myapp.data.ProviderLTD/TB_WIDGET3P、 uidが= 10013は、プロバイダをエクスポートする必要があり、またはgrantUriPermission()
を私はマニフェストにProviderLTD(私のコンテンツプロバイダ)をエクスポートする場合、それは動作しますが、Iそれをエクスポートすることを避けたい。
他の解決策はgrantUriPermission()です。私は、マニフェストでgrantUriPermissionsをtrueに設定しましたが、今では自分のコードのどこに権限を与えなければならないのか分かりません。
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
}
}