Add more info of crash logs
This commit is contained in:
parent
16c3679cd0
commit
1907f1d0aa
3 changed files with 36 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package cn.super12138.todo.views.crash
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.ViewGroup
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
|
|
@ -8,6 +9,9 @@ import androidx.core.view.WindowInsetsCompat
|
|||
import androidx.core.view.updateLayoutParams
|
||||
import cn.super12138.todo.databinding.ActivityCrashBinding
|
||||
import cn.super12138.todo.views.BaseActivity
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.Locale
|
||||
|
||||
class CrashActivity : BaseActivity() {
|
||||
private lateinit var binding: ActivityCrashBinding
|
||||
|
|
@ -30,7 +34,36 @@ class CrashActivity : BaseActivity() {
|
|||
}
|
||||
|
||||
val crashLogs = intent.getStringExtra("crash_logs")
|
||||
binding.crashLog.text = crashLogs
|
||||
|
||||
val deviceBrand = Build.BRAND
|
||||
val deviceModel = Build.MODEL
|
||||
val sdkLevel = Build.VERSION.SDK_INT
|
||||
val currentDateTime = Calendar.getInstance().time
|
||||
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
||||
val formattedDateTime = formatter.format(currentDateTime)
|
||||
|
||||
val pkgInfo = packageManager.getPackageInfo(packageName, 0)
|
||||
val verName = pkgInfo.versionName
|
||||
val verCode = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
pkgInfo.longVersionCode.toInt()
|
||||
} else {
|
||||
pkgInfo.versionCode
|
||||
}
|
||||
val mergeVer = "$verName($verCode)"
|
||||
|
||||
val deviceInfo = StringBuilder().apply {
|
||||
append("ToDo version: ").append(mergeVer).append('\n')
|
||||
append("Brand: ").append("").append(deviceBrand).append('\n')
|
||||
append("Model: ").append(deviceModel).append('\n')
|
||||
append("Device SDK: ").append(sdkLevel).append('\n').append('\n')
|
||||
append("Crash time: ").append(formattedDateTime).append('\n').append('\n')
|
||||
append("======beginning of crash======").append('\n')
|
||||
}
|
||||
|
||||
binding.crashLog.text = StringBuilder().apply {
|
||||
append(deviceInfo)
|
||||
append(crashLogs)
|
||||
}
|
||||
|
||||
binding.exitApp.setOnClickListener {
|
||||
this.finishAffinity()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<string name="check_update">检查更新</string>
|
||||
<!--Crash Activity-->
|
||||
<string name="error_title">应用程序出现错误</string>
|
||||
<string name="error_tips">别担心,下方是错误日志,请全选复制然后把它发送给我,我会尽快解决问题</string>
|
||||
<string name="error_tips">别担心,下方是错误日志,请全选复制然后反馈到 GitHub Issues,我会尽快解决问题</string>
|
||||
<string name="no_crash_logs">没有日志传入</string>
|
||||
<string name="exit_app">退出应用</string>
|
||||
<!--Subjects-->
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<string name="view_source">View source on GitHub</string>
|
||||
<!--Crash Activity-->
|
||||
<string name="error_title">Oops! App went wrong</string>
|
||||
<string name="error_tips">Don\'t worry, crash logs under there! Please copy them and send to me, I\'ll solve this problem</string>
|
||||
<string name="error_tips">Don\'t worry, below is the error log. Please select all and copy it, and then provide feedback on GitHub Issues. I will resolve the issue as soon as possible.</string>
|
||||
<string name="no_crash_logs">No crash logs</string>
|
||||
<string name="exit_app">Exit app</string>
|
||||
<!--Subjects-->
|
||||
|
|
|
|||
Loading…
Reference in a new issue