【问题标题】:How to start a new activity from another app while in kiosk mode?如何在展台模式下从另一个应用程序启动新活动?
【发布时间】:2018-06-19 19:22:32
【问题描述】:

我有两个应用启用了自助服务终端模式。我目前从一个发送一个广播到另一个传输数据。我想告诉接收应用程序开始一个新活动。

在大多数情况下,我可以使用 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);但是...在自助服务终端模式下,我无法开始新任务。

这是我在广播接收器中的内容(我已验证它适用于其他数据)。此代码尝试启动一个新活动:

            Intent launchIntent = new Intent(Intent.ACTION_MAIN);
            launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this doesn't work in kiosk mode...
            launchIntent.setComponent(new ComponentName("my.package","my.package.myactivity"));
            try {
                if(launchIntent != null) {
                    context.getApplicationContext().startActivity(launchIntent);
                    Log.i(TAG, "Started activity");
                } else
                    Log.i(TAG, "Intent is null");
            } catch (Exception e) {
                Log.e(TAG, e.toString());
            }

我在添加标志之前的错误:

Kiosk Mode: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

加上flag之后:

E/ActivityManager(  470): Attempted Lock Task Mode violation

是否可以通过广播接收器发送上下文,以便我可以使用该上下文启动所需的活动?除了使用广播开始新活动之外,任何人都可以提出其他方法吗?

【问题讨论】:

    标签: android android-intent kiosk-mode


    【解决方案1】:

    注意:在Android“ScreenPinning”中,“Kioskmode”和“Lock Task Mode”是一样的。

    来自https://developer.android.com/about/versions/android-5.0.html#ScreenPinning

    Once your app activates screen pinning, users cannot (...) 
    access other apps (...) until your app exits the mode.
    

    您必须通过 stopLockTask() 交互来临时禁用 kioskmode 并使用 startLockTask() 重新启用它

    为了防止 android 要求用户重新启动 kioskmode,您还需要实现一个 https://developer.android.com/about/versions/android-5.0.html#DeviceOwner 应用程序

    你可以在https://github.com/Tuong-Nguyen/Android/wiki/Research-114-Kiosk-Mode-Android-application找到很多关于这个话题的信息

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-18
      相关资源
      最近更新 更多