在Android Locktask模式下执行通话 [英] Perform calls in Android Locktask mode

查看:99
本文介绍了在Android Locktask模式下执行通话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TL; DR如何在使用 Activity.startLockTask()时拨打电话?

TL;DR How to make a phone call while using Activity.startLockTask()?

我正在尝试在Android设备上设置受限制的环境,即通常称为信息亭模式"的内容.

I'm trying to setup a restricted environment on an Android device, i.e. what is usually called "Kiosk-Mode".

官方文档可以在这里找到: https://developer.android.com/work/cosu.html

Official documentation can be found here: https://developer.android.com/work/cosu.html

执行此操作的官方方法建议使用活动.startLockTask .

The official way of doing this suggest to use Activity.startLockTask.

这很好,直到您要从处于 startLockTask()模式的 Activity 中启动其他应用程序为止.启动的任何活动都不得在新任务堆栈上启动,否则系统会阻止启动意图,即否 Intent.FLAG_ACTIVITY_NEW_TASK .

This works fine until you want to start other apps from within your Activity which is in startLockTask() mode. Any activity that launches must not start on a new task stack otherwise the system blocks the launch intent, i.e. no Intent.FLAG_ACTIVITY_NEW_TASK.

某些应用程序只能启动,其他应用程序似乎可以隐式设置此标志,但是可以通过使用 startActivityForResult(...)来解决,该应用程序似乎删除了 NEW_TASK 标志.对于仍然无法正常运行的应用,我可以编写自己的替换代码.

Some apps can just be launched, other seem to implicitly set this flag, but can be workedaround by using startActivityForResult(...) which seems remove the NEW_TASK flag. For apps that still don't work I could code my own replacement.

真正的问题是调用应用程序,该应用程序强制执行新的任务堆栈.触发呼叫会启动呼叫,不会显示呼叫活动,但还会在状态栏中显示呼叫通知(使用 startLockTask()时无法访问该通知).与其他应用程序相比,呼叫应用程序也不能用自定义应用程序替代...

The real issue is the call application, which enforces a new task stack. Triggering a call initiated the call, doesn't show the call activity, but also puts a call notification in the status bar (which is not accessible in while using startLockTask(). In contrast to other apps the call app is also one that can't be replaced with a custom app...

DevicePolicyManager.html.setLockTaskPackages()对此行为没有影响.

推荐答案

我试图在锁定模式下使开始呼叫意图生效,并弹出以下行:

I tried to make start call intent under locked mode and this line pop up:

    system_process E/ActivityManager: Attempted Lock Task Mode violation mStartActivity=ActivityRecord{56ab302 u0 com.android.server.telecom/.components.UserCallActivity t155}

所以我添加

    setLockTaskPackages(<ComponentName>,new String[]{getPackageName(),"com.google.android.dialer","com.android.server.telecom"});

设法使拨号器退出.当然,如果我按下主屏幕按钮或后退按钮,则无法恢复拨号器……尽管最近的按钮仍处于锁定状态.接听电话效果很好(所有按钮均被禁用)

Managed to get the dialler out. Of course if I push the home button or back button, there's no way to get the dialler back... the recent button is still locked though. Receiving call works perfectly (all buttons are disabled)

这篇关于在Android Locktask模式下执行通话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆