简体   繁体   English

在呼叫仍处于活动状态时如何隐藏拨号器意图

[英]How to hide the dialer intent while the call still active

I've the below code that launch the Dialer intent, and make a call with the given number. 我有以下代码启动Dialer意图,并使用给定号码拨打电话。

I need to minimize/hide this activity, so I'm making a delay of 15 seconds that call the Press home intent but t is not working. 我需要最小化/隐藏此活动,因此我要延迟15秒以调用Press home intent但t无法正常工作。 How can I hide the dialer while it still active (ie still making the required call)! 在拨号程序仍处于活动状态(即仍在拨打所需的电话)时,如何隐藏它!

if (isChecked) {
    val dial = "tel:12345678"
    val phoneIntent = Intent(Intent.ACTION_CALL, Uri.parse(dial))

    val startMain = Intent(Intent.ACTION_MAIN).apply {
        addCategory(Intent.CATEGORY_HOME)
        flags = Intent.FLAG_ACTIVITY_NEW_TASK
    }

    val r = java.lang.Runnable {
            context.startActivity(startMain)
        }

    context.startActivity(phoneIntent)
    val h = Handler()
    h.postDelayed(r, 15000) // will be delayed for 15 seconds
}

I managed it using the below code, but not clear wha is the different between this and the above one in the question: 我使用以下代码对其进行了管理,但不清楚该问题与上述问题之间的区别:

Thread().run {
    context.startActivity(phoneIntent)
    Thread.sleep(2000)
    context.startActivity(startMain)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM