From b9feb886f895afb1480fcecfbcc3339e9e2d7913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Tue, 7 Jun 2022 00:47:07 +0100 Subject: [PATCH] Fix sharing log files on newer android versions --- .../gadgetbridge/activities/DebugActivity.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java index d34ec7760..a1a1dc3ee 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DebugActivity.java @@ -57,6 +57,7 @@ import android.widget.Toast; import androidx.core.app.NavUtils; import androidx.core.app.NotificationCompat; import androidx.core.app.RemoteInput; +import androidx.core.content.FileProvider; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import org.slf4j.Logger; @@ -681,10 +682,17 @@ public class DebugActivity extends AbstractGBActivity { return; } + final Uri providerUri = FileProvider.getUriForFile( + this, + getApplicationContext().getPackageName() + ".screenshot_provider", + logFile + ); + Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); + emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); emailIntent.setType("*/*"); emailIntent.putExtra(EXTRA_SUBJECT, "Gadgetbridge log file"); - emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(logFile)); + emailIntent.putExtra(Intent.EXTRA_STREAM, providerUri); startActivity(Intent.createChooser(emailIntent, "Share File")); } }