fix share error

This commit is contained in:
ShirosakiMio 2024-06-27 07:43:19 +08:00
parent 8bf3927d20
commit e167716b33
4 changed files with 13 additions and 8 deletions

View File

@ -118,17 +118,23 @@
android:enabled="true"/> android:enabled="true"/>
<provider <provider
android:name=".scoped.FolderProvider" android:name=".scoped.FolderProvider"
android:authorities="@string/file_browser_provider" android:authorities="@string/file_browser_document_provider"
android:exported="true" android:exported="true"
android:grantUriPermissions="true" android:grantUriPermissions="true"
android:permission="android.permission.MANAGE_DOCUMENTS"> android:permission="android.permission.MANAGE_DOCUMENTS">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
<intent-filter> <intent-filter>
<action android:name="android.content.action.DOCUMENTS_PROVIDER" /> <action android:name="android.content.action.DOCUMENTS_PROVIDER" />
</intent-filter> </intent-filter>
</provider> </provider>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="@string/file_browser_provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
</application> </application>
<queries> <queries>
<package android:name="net.kdt.pojavlaunch.ffmpeg"/> <package android:name="net.kdt.pojavlaunch.ffmpeg"/>

View File

@ -278,11 +278,10 @@ public class JVMCrashActivity extends FCLActivity implements View.OnClickListene
File file = File.createTempFile("fcl-latest", ".log"); File file = File.createTempFile("fcl-latest", ".log");
FileUtils.writeText(file, error.getText().toString()); FileUtils.writeText(file, error.getText().toString());
Uri uri = FileProvider.getUriForFile(this, getString(com.tungsten.fcllibrary.R.string.file_browser_provider), file); Uri uri = FileProvider.getUriForFile(this, getString(com.tungsten.fcllibrary.R.string.file_browser_provider), file);
intent.setType("*/*"); intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_STREAM, uri); intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivity(Intent.createChooser(intent, getString(com.tungsten.fcllibrary.R.string.crash_reporter_share))); startActivity(Intent.createChooser(intent, getString(com.tungsten.fcllibrary.R.string.crash_reporter_share)));
} catch (Exception e) { } catch (Exception e) {
LOG.log(Level.INFO, "Share error: " + e); LOG.log(Level.INFO, "Share error: " + e);

View File

@ -75,11 +75,10 @@ public class CrashReportActivity extends FCLActivity implements View.OnClickList
File file = File.createTempFile("crash_report", ".txt"); File file = File.createTempFile("crash_report", ".txt");
Files.write(file.toPath(), CrashReporter.getAllErrorDetailsFromIntent(this, getIntent()).getBytes(StandardCharsets.UTF_8)); Files.write(file.toPath(), CrashReporter.getAllErrorDetailsFromIntent(this, getIntent()).getBytes(StandardCharsets.UTF_8));
Uri uri = FileProvider.getUriForFile(this, getString(R.string.file_browser_provider), file); Uri uri = FileProvider.getUriForFile(this, getString(R.string.file_browser_provider), file);
intent.setType("*/*"); intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_STREAM, uri); intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivity(Intent.createChooser(intent, getString(R.string.crash_reporter_share))); startActivity(Intent.createChooser(intent, getString(R.string.crash_reporter_share)));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="file_browser_provider" translatable="false">com.tungsten.fcl.provider</string> <string name="file_browser_provider" translatable="false">com.tungsten.fcl.provider</string>
<string name="file_browser_document_provider" translatable="false">com.tungsten.fcl.document.provider</string>
<string name="file_browser_title">File Browser</string> <string name="file_browser_title">File Browser</string>
<string name="file_browser_back">Back</string> <string name="file_browser_back">Back</string>
<string name="file_browser_close">Exit</string> <string name="file_browser_close">Exit</string>