Reconnecting to the Instruction Stream Cloud Phone
Application Scenario
Execute the instruction stream cloud phone connection process again when the client socket is disconnected.
Prerequisites
The client socket is disconnected.
Development Process
In the started logic threads, call the stop, initialize, and start APIs of the instruction stream engine in sequence.
Encoding Instance
public class Activity implements BaseActivity {
protected void ReconnectCloudPhone() {
threadPool.submit(new ReconnectRunnable());
}
}
class ReconnectRunable implements Runnable {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
// Stop the instruction stream engine.
engine.stop();
// Initialize the instruction stream engine.
int initResult = engine.initialize();
if (initResult != InstructionEngine.VMI_SUCCESS) {
// Failed to initialize the instruction stream engine.
}
// Start the instruction stream engine.
int startResult = engine.start(surfaceView.getHolder().getSurface(),
guestWidth, guestHeight, metric.densityDpi);
if (startResult == InstructionEngine.VMI_CLIENT_START_FAIL) {
// Failed to start the instruction stream engine.
} else {
// The instruction stream engine is successfully started. Start the receive thread.
}
}
});
}
}
Parent topic: API Development Process