android - RemoteViewsFactory grantUriPermission to fetch data -


have appwidget listview want populate remoteviewsservice.remoteviewsfactory.

i have 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 pid=413, uid=10013 requires provider exported, or granturipermission()

if export providerltd (my content provider) in manifest works, i'd avoid export it.

the other solution granturipermission(). set granturipermissions true in manifest, don't understand in code have grant 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 populate listview             // fillinintent listeners             return myremoteviews;         }          public void ondatasetchanged() {             mwidgetitems = new arraylist<objw3task>();             // create mwidgetitems accessing contentprovider class         } } 

not sure if still relevant; found works on mine, setting "android:exported = true":

<provider android:name="weatherdataprovider" android:exported="true"> 

see this: android permission denial in widget remoteviewsfactory content


Comments