[Question] rtmpdisplay disconnect self suddenly
Device: HTC_A9u Android 7.0 IDE: Android Studio 3.1.3 on Mac with Java 8.0 Sdk Version: min = 21, target = 27, compile = 27
I want to screencast my playing game app and stream it to server.
code step: // I try it in (a.) activity and (b.) IntentService (c.) use getApplicationContext(), when onCreate()
- rtmpDisplay = new RtmpDisplay(this, false,this);
- startActivityForResult(rtmpDisplay.sendIntent(), REQUEST_SCREEN_RECORD);
- rtmpDisplay.prepareAudio() && rtmpDisplay.prepareVideo(width, height, 30, 1000 * 1024, 0, 320)
- rtmpDisplay.setIntentResult(resultCode, data);
- rtmpDisplay.startStream(rtmpUrl); then I can start rtmp success I open a ALERT_WINDOW to control the rtmp. The connect will disconnect self suddenly(about 1s ~ 30m) when I open other app.
I don't want it stop by itself. Is any wrong or step I need to do for this case? Thank you for watch it.
Is my example working for you? Remember that you can't close app totally (only send to background) or your rtmpdisplay object will be recycled. For example, in my example, start stream and press home button to send background (you know that work because when you reopen app and go to activity you will see stop stream instead of start stream).
Other way is do a service that no die when you close app (foreground service): https://stackoverflow.com/questions/42126979/cannot-keep-android-service-alive-after-app-is-closed
I use foreground service success, thank you.