问题描述
当我尝试启动活动意图时,Android-O中新的ActivityOptions setLaunchDisplayId(int launchDisplayId)函数似乎总是使我的应用程序崩溃.
The new ActivityOptions setLaunchDisplayId (int launchDisplayId) function in Android-O seems to always crash my app when I try to launch an activity intent.
当我从自己的应用程序启动活动以及尝试启动其他应用程序(例如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:
下面是我的代码的一小段:
A small snippet of my code is below:
options.setLaunchDisplayId(1);startActivity(intent,options);
注意我正在测试是否启用模拟第二个屏幕"(如果有问题,请使用@ 1080p).
NOTEI was testing with 'simulate a second screen' enabled (@1080p if it matters).
更新我已经尝试过ADB命令 adb shell start com.chrome.canary --display 1
,然后我得到消息:
UPDATEI have tried the ADB command adb shell start com.chrome.canary --display 1
,and I get the message:
推荐答案
我已通过带有以下代码的新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在辅助显示屏上启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!