I have integrated video chat using Opentok and it works really well but the issue I'm facing now is that it will work only if both of us open up the app. What the requirement is that we should be able to make video call even if the other user has not opened up the app. Please help me in this and thanks in advance.
Firstly, you need a Service which is controlling the connection running in the background which generates its own Thread()
to perform and mantain the Server
connection.
If you want the service to be "unkillable" use the START_STICKY
variable at the start of the service.
Keep this alive by requesting WAKE_LOCK
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"MyWakelockTag");
wakeLock.acquire();
And include the permission
android.permission.WAKE_LOCK
Then, have the Service Start the Main Activity for viewing a connection.
You can do this through the Intent Service withstartActivityForResult
and just make sure you get that the connection was correctly started up on the view or if already bound to the activity pass over the correct veriables/parceables/etc. Just remember to do effective management using the onPause
It's some re-writing, but not too bad. Good example code for this can be found in the CSIPSimple application code.