三个点,Display-addSecondary display
方案一
通过Presentation来实现,他是一个Dialog(context,display)
val displayService = getSystemService(DISPLAY_SERVICE) as DisplayManager
val displays = displayService.displays
for (display in displays){
Log.i("alic",display.toString())
}
if (displays.size > 1){
Log.i("alic show",displays[1].toString())
var p:Presentation = DifferentDisplay(this, displays[1])
p.show()
}
package com.example.myapplication;
import android.app.Presentation;
import android.content.Context;
import android.os.Bundle;
import android.view.Display;
public class DifferentDisplay extends Presentation {
public DifferentDisplay(Context outerContext, Display display) {
super(outerContext, display);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.different_display);
}
}
方案二
使用ActivityOptions设置activity显示在哪个屏幕上 launchDisplayId
val options = ActivityOptions.makeBasic()
options.launchDisplayId = 2
val secondIntent = Intent()
val cn = ComponentName("com.example.myapplication","com.example.myapplication.SecondActivity")
secondIntent.component = cn
secondIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(secondIntent,options.toBundle())
方案三文章来源:https://www.toymoban.com/news/detail-530868.html
adb shell am start -n 包名+Activity文章来源地址https://www.toymoban.com/news/detail-530868.html
adb shell am start -n com.example.myapplication/com.example.myapplication.MainActivity --display 2
到了这里,关于android车载开发,如何模拟器上实现多屏的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!