I don't understand how to use this to do URI based permissions on a restricted Content Provider.
Here is what I did (did not work):
1. made an Activity (GrantAccess) in the same application as the Content Provider with access to it. Only important code is this:
All it does is put the uri into the intent and set the FLAG_GRANT_READ_URI_PERMISSION. returning the intent to the calling activity.
2. From an activity with no access to the Content Provider, use startActivityForResult to invoke the above activity (GrantAccess) and have an onActivityResult method to get back the intent.
Now I am stuck. I want to use the uri inside the intent returned to query the content provider but I don't know how to do it. Getting the uri from the intent with getData() method and using it in the resolver's query gives denied access error. Does anyone know how to do this?
Here is what I did (did not work):
1. made an Activity (GrantAccess) in the same application as the Content Provider with access to it. Only important code is this:
Code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Uri u = Text.CONTENT_URI3; // content://com.test/text/1
setResult(1, new Intent().setData(u).addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION).setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION));
}
2. From an activity with no access to the Content Provider, use startActivityForResult to invoke the above activity (GrantAccess) and have an onActivityResult method to get back the intent.
Now I am stuck. I want to use the uri inside the intent returned to query the content provider but I don't know how to do it. Getting the uri from the intent with getData() method and using it in the resolver's query gives denied access error. Does anyone know how to do this?