【问题标题】:How to finish the app and return to previous screen如何完成应用程序并返回上一屏幕
【发布时间】:2020-12-22 09:52:42
【问题描述】:

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

我的代码:

  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: 访问被拒绝查找属性“ro.vendor.df.effect.conflict”

2020-09-03 10:25:39.588 20181-20253/com.example.shareway E/Perf: 失败 获取文件列表 com.example.shareway 2020-09-03 10:25:39.590

20181-20253/com.example.shareway E/Perf:getFolderSize():Exception_1 = java.lang.NullPointerException: 尝试获取空数组的长度

我怎样才能退出应用程序并返回到上一个屏幕而不会出现错误?

【问题讨论】:

    标签: android kotlin android-intent kotlin-coroutines


    【解决方案1】:

    嗯..我的错。

    代码完全没问题,我只是忘了移动

      progressBar.visibility = View.GONE
    

    到主线程

    【讨论】:

      猜你喜欢
      • 2021-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多