Support

What interfaces do I need to implement?

As part of the Android implementation, you will need to implement the LayerConnectionListener and LayerAuthenticationListener interfaces. These interfaces are important as they facilitate connecting and authenticating with Layer. You will then need to register these implementations with the LayerClient.

Example AuthenticationListener implementation.


public class AuthenticationListener implements LayerAuthenticationListener {

	@Override
	public void onAuthenticated(LayerClient client, String arg1) {
		System.out.println("Authentication successful");
		
	}

	@Override
	public void onAuthenticationChallenge(LayerClient client, String nonce) {
		
	}
	
	@Override
	public void onAuthenticationError(LayerClient layerClient, int arg1, String arg2) {
		// TODO Auto-generated method stub
		System.out.println("There was an error authenticating");
	}

	@Override
	public void onDeauthenticated(LayerClient client) {
		// TODO Auto-generated method stub
		
	}

}

Example ConnectionListener implementation.


public class ConnectionListener implements LayerConnectionListener {

	@Override
	public void onConnectionConnected(LayerClient client) {
		client.authenticate();
	}

	@Override
	public void onConnectionDisconnected(LayerClient arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onConnectionError(LayerClient arg0, int arg1, String arg2) {
		// TODO Auto-generated method stub
		
	}

}

After both are implemented, you can register them on the LayerClient object.


//Register a connection listener and an authentication listener
client.registerConnectionListener(new ConnectionListener()).registerAuthenticationListener(new AuthenticationListener());
Have more questions? Submit a request