Android-O 在辅助显示器上启动 [英] Android-O launch on secondary display

查看:70
本文介绍了Android-O 在辅助显示器上启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android-O 中新的 ActivityOptions setLaunchDisplayId (int launchDisplayId) 函数似乎总是在我尝试启动 Activity Intent 时使我的应用崩溃.

The new ActivityOptions setLaunchDisplayId (int launchDisplayId) function in Android-O seems to always crash my app when I try to launch an activity intent.

当我从自己的应用启动 Activity 以及尝试启动其他应用(例如 Chrome Canary)时.

Both when I launch activities from my own app and when I try to launch other apps i.e. Chrome Canary.

有谁知道这是新 API 的普遍问题还是我遗漏了什么:

Does anyone know if this is a general problem with the new API's or am I missing something:

我的一小段代码如下:

options.setLaunchDisplayId(1);startActivity(intent, options);

注意我正在测试启用模拟第二个屏幕"(@1080p,如果重要).

NOTE I was testing with 'simulate a second screen' enabled (@1080p if it matters).

更新我已经尝试了 ADB 命令 adb shell start com.chrome.canary --display 1,我收到消息:

UPDATE I have tried the ADB command adb shell start com.chrome.canary --display 1, and I get the message:

开始:必须是 root

start: must be root

推荐答案

我已经通过新的 API 和下面的代码连接到第二个屏幕,但目前还没有办法与之交互.

I have connected to the second screen via the new API's with the code below, but as of yet have no way of interacting with it.

 Bundle bdl;
 MediaRouter mediaRouter = (MediaRouter) mContext.getSystemService(Context.MEDIA_ROUTER_SERVICE);
 MediaRouter.RouteInfo route = mediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO);
 if (route != null) {
     Display presentationDisplay = route.getPresentationDisplay();
     bdl = ActivityOptions.makeClipRevealAnimation(mView, left, top, width, height).setLaunchBounds(rect).setLaunchDisplayId(presentationDisplay.getDisplayId()).toBundle();
     Bundle optsBundle = true ? bdl : null;
     Intent intent = new Intent(mContext, SecondaryActivity.class);
     intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     mContext.startActivity(intent, optsBundle);
 }

这篇关于Android-O 在辅助显示器上启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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