Я пытаюсь создать приложение для потоковой передачи видео на моем дополнительном дисплее, подключенном через HDMI на моем устройстве, в режиме презентации Android. Я запустил простой макет на вторичном дисплее, и я смог это сделать. Но когда я запускаю свое приложение, он блокирует экран Activity на основном экране, и я не могу ничего сделать, кроме как убить приложение.Режим презентации Android
Этот код я нашел где-то в Интернете. Это простой код, и он набрасывает «R.layout.presentation_with_media_router_content» на моем вторичном экране, но я ничего не могу сделать на своем основном экране, пока не убью это приложение из adb.
Оба экрана подключены через HDMI (HDMI 1 & HDMI 2). Любая помощь в том, как включить мой основной дисплей во время работы режима презентации на вторичном, поможет. Кстати, я использую Android N для этой разработки.
public class MainActivity extends AppCompatActivity {
ImageButton sendtoback;
private PresentationActivity presentationActivity;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// init Presentation Class
DisplayManager displayManager = (DisplayManager) this.getSystemService(Context.DISPLAY_SERVICE);
Display[] presentationDisplays = displayManager.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION);
if (presentationDisplays.length > 0) {
// If there is more than one suitable presentation display, then we could consider
// giving the user a choice. For this example, we simply choose the first display
// which is the one the system recommends as the preferred presentation display.
Display display = presentationDisplays[0];
PresentationActivity presentation = new PresentationActivity(this, display);
presentation.show();
this.presentationActivity = presentation;
}
}
public void changeText (String s) {
this.presentationActivity.setText(s);
}
public void SendOnBack(View view){
Log.i("VideoApp","StartVideoApp");
}
}
class PresentationActivity extends Presentation {
private TextView text;
private PresentationActivity presentation;
public PresentationActivity(Context outerContext, Display display) {
super(outerContext, display);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.presentation_with_media_router_content);
TextView text = (TextView) findViewById(R.id.textView1);
this.text = text;
text.setText("test");
}
public void setText(String s) {
this.text.setText(s);
}
}
Спасибо, Сатиш