在twilio来电中未调用Android挂起的意图

时间:2017-04-14 11:18:35

标签: android twilio voip android-pendingintent

我正在使用twilio sdk调用应用程序我已经整合了所有的东西,它处于工作状态。但问题是当我的Android应用程序长时间保留在后台时,应用程序没有收到传入的呼叫请求,未被twilio调用的未决意图这是代码:

   if (!Twilio.isInitialized()) {
            /*
         * Needed for setting/abandoning audio focus during call
         */
            Twilio.initialize(context, new Twilio.InitListener() {

                /*
                 * Now that the SDK is initialized we can register using a Capability Token.
                 * A Capability Token is a JSON Web Token (JWT) that specifies how an associated Device
                 * can interact with Twilio services.
                 */
                @Override
                public void onInitialized() {
                    isInitialized = true;
                    Twilio.setLogLevel(Log.VERBOSE);
                    /*
                     * Retrieve the Capability Token from your own web server
                     */
                    retrieveCapabilityToken();
                }

                @Override
                public void onError(Exception e) {
                    isInitialized = false;
                    Logging.e(TAG, e.toString());
                    notifyOnStopListening(null,-1,context.getString(R.string.error_message_not_connecting));
                }
            });

        } else { 
            retrieveCapabilityToken();
        }
  }

private void retrieveCapabilityToken() {
// in the success of api response 
    if (clientDevice == null) {
            clientDevice = Twilio.createDevice(capabilityToken,deviceListener);
        }
         if(clientDevice != null) {                
            Intent intent = new Intent(context, ReceiveCallActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
            clientDevice.setIncomingIntent(pendingIntent);
            isIntentAdded = true;
            Logging.e(TAG,"in addPendingIntent intent added");
        }
}

任何建议,帮助将不胜感激。

0 个答案:

没有答案