Skip to content

Commit c71475e

Browse files
authored
Merge pull request #34 from fyhbauyg/main
修复捕捉日志错误
2 parents 2a1446d + 38a8c53 commit c71475e

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

‎app/src/main/java/moe/reimu/catshare/SettingsActivity.kt‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package moe.reimu.catshare
22

3-
import android.app.Activity
43
import android.content.Intent
54
import android.os.Bundle
5+
import android.os.Handler
6+
import android.os.Looper
67
import android.util.Log
78
import android.widget.Toast
89
import androidx.activity.ComponentActivity
@@ -152,15 +153,17 @@ fun SettingsActivityContent() {
152153
val intent = Intent(Intent.ACTION_SEND)
153154
.putExtra(Intent.EXTRA_STREAM, uri)
154155
.setType("text/plain")
155-
.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
156+
.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NEW_TASK)
156157
context.startActivity(intent)
157158
} catch (e: Exception) {
158159
Log.e("LogcatCapture", "Failed to save logs", e)
159-
Toast.makeText(
160-
context,
161-
context.getString(R.string.log_capture_failed),
162-
Toast.LENGTH_LONG
163-
).show()
160+
Handler(Looper.getMainLooper()).post {
161+
Toast.makeText(
162+
context,
163+
context.getString(R.string.log_capture_failed),
164+
Toast.LENGTH_LONG
165+
).show()
166+
}
164167
}
165168
}.start()
166169
}) {

0 commit comments

Comments
 (0)