2

I am working on sinch app to app call API, have integrated incoming and outgoing call screen.

My issue is, if call is ongoing and user removes application from backgroud, what will happen?

to overcome this issue, i have written call.hangup() in onDestroy() of activity, but it's neither hangingup sinch call nor giving any error.

@Override
protected void onDestroy() {
    super.onDestroy();
    call.hangup();
}

I have tried by putting super.onDestroy() after call.hangup() but that also didn't work.

Here is service class from where i am maintaining SinchClient :

public class SinchService extends Service
{
    public static SinchClient sinchClient;
    @Override
    public void onCreate() {
       super.onCreate();
       connect();
    }
    private void connect() {

        sinchClient = Sinch.getSinchClientBuilder().context(this)
                .applicationKey(getResources().getString(R.string.sinch_app_key))
                .applicationSecret(getResources().getString(R.string.sinch_app_secret))
                .environmentHost(getResources().getString(R.string.sinch_app_host))
                .userId(SharedPreferenceUtil.getString("user_id", ""))
                .build();

        sinchClient.setSupportMessaging(true);
        sinchClient.setSupportCalling(true);
        sinchClient.setSupportActiveConnectionInBackground(true);
        sinchClient.startListeningOnActiveConnection();
        sinchClient.addSinchClientListener(this);
        sinchClient.start();
    }

}
Ravi
  • 34,851
  • 21
  • 122
  • 183
  • Where is the sinch client maintained? In a service or in the activity? Cause if it’s in the activity, and the activity goes away and thus all JVM reference counts to the sinch Call object, then the “hangup” event will probably never make it. You should have it in a service. – cjensen May 10 '16 at 16:54
  • @cjensen yes sinch client is maintained inside service. You can see my updated question. – Ravi May 11 '16 at 04:21

0 Answers0