diff --git a/crashreporter/src/main/AndroidManifest.xml b/crashreporter/src/main/AndroidManifest.xml index a90930a..eb1c0a7 100644 --- a/crashreporter/src/main/AndroidManifest.xml +++ b/crashreporter/src/main/AndroidManifest.xml @@ -22,6 +22,17 @@ android:name=".ui.LogMessageActivity" android:parentActivityName=".ui.CrashReporterActivity" android:theme="@style/CrashReporter.Theme" /> + + + + + diff --git a/crashreporter/src/main/java/com/balsikandar/crashreporter/ui/LogMessageActivity.java b/crashreporter/src/main/java/com/balsikandar/crashreporter/ui/LogMessageActivity.java index 55c6fd2..1273723 100644 --- a/crashreporter/src/main/java/com/balsikandar/crashreporter/ui/LogMessageActivity.java +++ b/crashreporter/src/main/java/com/balsikandar/crashreporter/ui/LogMessageActivity.java @@ -2,7 +2,9 @@ import android.content.Intent; import android.net.Uri; +import android.os.Build; import android.os.Bundle; +import android.support.v4.content.FileProvider; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; @@ -75,10 +77,17 @@ public boolean onOptionsItemSelected(MenuItem item) { } private void shareCrashReport(String filePath) { + Uri uri; + Intent intent = new Intent(Intent.ACTION_SEND); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + uri = FileProvider.getUriForFile(getApplicationContext(), "com.balsikandar.crashreporter.files", new File(filePath)); + } else { + uri = Uri.fromFile(new File(filePath)); + } intent.setType("*/*"); intent.putExtra(Intent.EXTRA_TEXT, appInfo.getText().toString()); - intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(filePath))); + intent.putExtra(Intent.EXTRA_STREAM, uri); startActivity(Intent.createChooser(intent, "Share via")); } } diff --git a/crashreporter/src/main/res/xml/fileprovider_paths.xml b/crashreporter/src/main/res/xml/fileprovider_paths.xml new file mode 100644 index 0000000..ffa74ab --- /dev/null +++ b/crashreporter/src/main/res/xml/fileprovider_paths.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file