Error Handling

Error Notifications

Errors are communicated from the SDK through Android's LocalBroadcastManager. For more information about LocalBroadcastManager and how it is used, you can read the LocalBroadcastManager section from Android's Developer Guide

Registering and Unregistering a BroadcastReceiver for Notifications

In the JabberGuestCall class, we allow classes to register and listen for 4 types of event notifications: call control events, call state changed events, new call instance available events, and error events.

Developers should use JabberGuestCall.registerReceiver(Context context, BroadcastReceiver receiver) to register your BroadcastReceiver to receive notifications for all four type of events. Alternatively, you can use JabberGuestCall.registerReceiver(Context context, BroadcastReceiver receiver, IntentFilter filter) to receive notifications for only a given subset of events. There is also a corresponding JabberGuestCall.unregisterReceiver(BroadcastReceiver mBroadcastReceiver) api to unregister your BroadcastReceiver.

When your BroadcastReceiver receives a notification for an event, the notification will include an intent which contains more information about the nature of that notification. For example, when receiving an error notification, you can get the bundle from the intent and retrieve the error information using the documented keys. For more details about the events and the keys, please refer to the JabberGuestCall class in the API Reference.

The following example shows how you can create a BroadcastReceiver, register that BroadcastReceiver to JabberGuestCall to receive notifications, handle those notifications to receive error information, and finally unregister that BroadcastReceiver.

  
    BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (JabberGuestCall.ACTION_CALL_ERROR_EVENT.equals(action)) {
                processCallErrorEvent(intent);
            }
        }
    };
    
    // Error information can be retrieved from the bundle object of the intent.
    void processCallErrorEvent(Intent intent) {
    	Bundle errorBundle = intent.getExtras();
    	long category = errorBundle.getLong(JabberGuestCall.ARG_CATEGORY_LABEL);
        int title = errorBundle.getInt(JabberGuestCall.ARG_USER_TITLE_LABEL);
        int code = errorBundle.getInt(JabberGuestCall.ARG_CODE_LABEL);
        string internalMessage = errorBundle.getString(JabberGuestCall.ARG_INTERNAL_MESSAGE_LABEL);
        int userMessage = errorBundle.getInt(JabberGuestCall.ARG_USER_MESSAGE_LABEL);
        Serializable callState = errorBundle.getSerializable(JabberGuestCall.ARG_CALL_STATE_VALUE);
    }
    
    @Override
    protected void onStart() {
        super.onStart();

        // Register to receive events from JabberGuestCall
        JabberGuestCall.registerReceiver(this, mBroadcastReceiver);
    }

    @Override
    protected void onStop() {
        super.onStop();

        // Unregister to remove receiver from receiving the broadcast messages.
        JabberGuestCall.unregisterReceiver(mBroadcastReceiver);
    }    
    	

Developers can register for just the error event notifications with:

    IntentFilter errorFilter = new IntentFilter();
    errorFilter.addAction(ACTION_CALL_ERROR_EVENT);
    
    JabberGuestCall.registerReceiver(context, receiver, errorFilter);
    	

Logs

The SDK also provides a logging class so users can modify what logging levels are included in LogCat logs from the SDK, as well as facilitate adding logs of your own.

    // To include the Log class in your client.
    import com.cisco.jabber.guest.util.Log;