fixed sharing entry with file:// uri
This commit is contained in:
parent
a5115fb83b
commit
2bbe652b06
3 changed files with 28 additions and 1 deletions
|
@ -41,6 +41,16 @@
|
||||||
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
|
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
|
||||||
android:value="false" />
|
android:value="false" />
|
||||||
</activity>
|
</activity>
|
||||||
|
<!-- file provider to share files having a file:// URI -->
|
||||||
|
<provider
|
||||||
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
android:authorities="deckers.thibault.aves.fileprovider"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/provider_paths" />
|
||||||
|
</provider>
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.google.android.geo.API_KEY"
|
android:name="com.google.android.geo.API_KEY"
|
||||||
android:value="AIzaSyDf-1dN6JivrQGKSmxAdxERLM2egOvzGWs" />
|
android:value="AIzaSyDf-1dN6JivrQGKSmxAdxERLM2egOvzGWs" />
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.graphics.Bitmap;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Key;
|
import com.bumptech.glide.load.Key;
|
||||||
|
@ -18,6 +19,7 @@ import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.bumptech.glide.signature.ObjectKey;
|
import com.bumptech.glide.signature.ObjectKey;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -190,7 +192,16 @@ public class AppAdapterHandler implements MethodChannel.MethodCallHandler {
|
||||||
|
|
||||||
private void share(String title, Uri uri, String mimeType) {
|
private void share(String title, Uri uri, String mimeType) {
|
||||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
|
if (ContentResolver.SCHEME_FILE.equalsIgnoreCase(uri.getScheme())) {
|
||||||
|
String path = uri.getPath();
|
||||||
|
if (path == null) return;
|
||||||
|
String applicationId = context.getApplicationContext().getPackageName();
|
||||||
|
Uri apkUri = FileProvider.getUriForFile(context, applicationId + ".fileprovider", new File(path));
|
||||||
|
intent.putExtra(Intent.EXTRA_STREAM, apkUri);
|
||||||
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
} else {
|
||||||
intent.putExtra(Intent.EXTRA_STREAM, uri);
|
intent.putExtra(Intent.EXTRA_STREAM, uri);
|
||||||
|
}
|
||||||
intent.setType(mimeType);
|
intent.setType(mimeType);
|
||||||
context.startActivity(Intent.createChooser(intent, title));
|
context.startActivity(Intent.createChooser(intent, title));
|
||||||
}
|
}
|
||||||
|
|
6
android/app/src/main/res/xml/provider_paths.xml
Normal file
6
android/app/src/main/res/xml/provider_paths.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<paths>
|
||||||
|
<external-path
|
||||||
|
name="external_files"
|
||||||
|
path="." />
|
||||||
|
</paths>
|
Loading…
Reference in a new issue