1 line
1.9 KiB
Kotlin
1 line
1.9 KiB
Kotlin
package code.name.monkey.retromusic.activities.bugreport
|
|
|
|
import android.content.ActivityNotFoundException
|
|
import android.content.Intent
|
|
import android.net.Uri
|
|
import android.os.Bundle
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import code.name.monkey.retromusic.R
|
|
import code.name.monkey.retromusic.activities.bugreport.model.DeviceInfo
|
|
import kotlinx.android.synthetic.main.activity_error_handler.*
|
|
|
|
|
|
class ErrorHandlerActivity : AppCompatActivity() {
|
|
private var deviceInfo: DeviceInfo? = null
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
setContentView(R.layout.activity_error_handler)
|
|
|
|
deviceInfo = DeviceInfo(this)
|
|
|
|
clearAppData.setOnClickListener {
|
|
try {
|
|
val intent = Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
|
|
intent.data = Uri.parse("package:$packageName")
|
|
startActivity(intent)
|
|
} catch (e: ActivityNotFoundException) {
|
|
val intent = Intent(android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS)
|
|
startActivity(intent)
|
|
}
|
|
}
|
|
|
|
sendCrashLog.setOnClickListener {
|
|
val sendIntent = Intent(Intent.ACTION_SEND)
|
|
val subject = "Error report"
|
|
val body = intent.getStringExtra("error") + "\n" + deviceInfo!!.toString()
|
|
|
|
sendIntent.putExtra(Intent.EXTRA_EMAIL, arrayOf("monkeycodeapp@gmail.com"))
|
|
sendIntent.putExtra(Intent.EXTRA_TEXT, body)
|
|
sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject)
|
|
sendIntent.type = "message/rfc822"
|
|
|
|
startActivity(Intent.createChooser(sendIntent, "Send crash log"))
|
|
deleteFile("stack.trace")
|
|
}
|
|
|
|
showCrashError.text = String.format("%s", intent.getStringExtra("error"))
|
|
showCrashError.append(deviceInfo!!.toString())
|
|
}
|
|
}
|