How to finish the app and return to previous screen

Viewed 680

I'm launching my app via implicit intent from other application, and after I do some work I want to exit the app and go back to where I was.

My code:

  if (intent.type == MY_INTENT_TYPE) {
            CoroutineScope(Dispatchers.IO).launch {
                delay(5000)
                progressBar.visibility = View.GONE
                withContext(Dispatchers.Main) {
                    finish()
                }
            }
        }

The problem I that I'm getting those errors when I call finish()

2020-09-03 10:25:39.547 20181-20181/com.example.shareway E/libc: Access denied finding property "ro.vendor.df.effect.conflict"

2020-09-03 10:25:39.588 20181-20253/com.example.shareway E/Perf: Fail to get file list com.example.shareway 2020-09-03 10:25:39.590

20181-20253/com.example.shareway E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array

How can I exit from the app and get back to the previous screen without errors?

1 Answers

Well..my mistake.

The code is totally fine, I just forgot to move

  progressBar.visibility = View.GONE

To the main thread

Related