I'm building a Chooser app that replaces the native Android Share dialog. It works fine except when I try to share an image from Chrome via longpress image > share image.
If I try to do: Focus Gallery (by Franco) > Share (My App) > Google+ > No problem. Chrome > Share (My App) > Crash.
As soon as I try to access the content:// uri that is passed to my app as the EXTRA_STREAM, I get an error:
java.lang.SecurityException: Permission Denial: opening provider org.chromium.chrome.browser.util.ChromeFileProvider from ProcessRecord{9a9ad72 13494:com.rejh.sharedr/u0a226} (pid=13494, uid=10226) that is not exported from UID 10101
The content uri looks like this:
content://com.android.chrome.FileProvider/images/screenshot/15307085865714015389178311011200.jpg
Here's what I do (simplified):
@override
public void onCreate() {
handleIntent();
@override
public void onNewIntent() {
handleIntent();
}
public void handleIntent() {
Parcelable parcel = getIntent().getParcelableExtra(Intent.EXTRA_INTENT);
payloadIntent = new Intent((Intent) parcel);
Uri extraStreamUri = (Uri) payloadIntent.getExtras().get(Intent.EXTRA_STREAM);
ContentResolver contentResolver = getContentResolver();
String fileMimeType = contentResolver.getType(extraStreamUri);
Cursor returnCursor = contentResolver.query(extraStreamUri, null, null, null, null);
}
I get the error on the last line (contentResolver.query()). Weirdly enough, getType() does work.
Manifest declaration of the activity:
<activity
android:name=".ActShareReplace"
android:label="Sharedr"
android:theme="@style/AppTheme.TransparentActivity"
>
<intent-filter>
<action android:name="android.intent.action.CHOOSER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
As far as I can tell I should still have access to the URI since I try to access it from the same activity that receives the intent.
Btw, Chrome is the only app I've been having problems with so far. A user did report that sharing an image from Whatsapp resulted in similar error(s).