Use recreate() to recreae Main Activity after restart by Android

This commit is contained in:
Juha Heinanen
2022-02-18 09:18:09 +02:00
parent a112cbbb22
commit 4f7278e3d7
2 changed files with 3 additions and 5 deletions

View File

@ -315,14 +315,14 @@ class BaresipService: Service() {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
val action: String?
val action: String
if (intent == null) {
action = "Start"
Log.d(TAG, "Received onStartCommand with null intent")
} else {
// Utils.dumpIntent(intent)
action = intent.action
action = intent.action!!
Log.d(TAG, "Received onStartCommand action $action")
}

View File

@ -927,9 +927,7 @@ class MainActivity : AppCompatActivity() {
Log.d(TAG, "Handling service event 'started' with '$callActionUri'")
if (!this::uaAdapter.isInitialized) {
// Android has restarted baresip when permission has been denied in app settings
val i = Intent(this, MainActivity::class.java)
i.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
startActivity(i)
recreate()
return
}
uaAdapter.notifyDataSetChanged()