如何完成应用程序并 return 返回上一屏幕

How to finish the app and return to previous screen

我正在通过其他应用程序的隐式意图启动我的应用程序,在我完成一些工作后我想退出应用程序并返回到原来的位置。

我的代码:

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

我在调用 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

如何退出应用程序并返回到上一个屏幕而不出现错误?

好吧..我的错误。

代码完全没问题,就是忘记动了

  progressBar.visibility = View.GONE

到主线程