This page provides a reference for the Gruveo SDK for Android and lists the methods and events exposed by the SDK.
Once all of the prerequisites are in place, the initialization of a Gruveo screen looks as follows:
1 2 3 4 5 | val result = Gruveo.Builder(activity) .callCode("gruveorocks") .clientId("demo") .eventsListener(eventsListener) .build() |
callCode(code:String)
clientId(clientId:String)
eventsListener(listener:Gruveo.EventsListener)
videoCall(video:Boolean)
true
.requestCode(code:Int)
onActivityResult
. code
is an identifying integer used as the second parameter in startActivityForResult(intent, requestCode)
.otherExtras(bundle:Bundle)
Gruveo.GRV_EXTRA_VIBRATE_IN_CHAT
(boolean) - whether to vibrate upon receiving incoming text chat messagesGruveo.GRV_EXTRA_DISABLE_CHAT
(boolean) - whether to disable the text chat functionality completely.The constructor returns one of the following values:
Gruveo.GRV_INIT_OK
- everything went fineGruveo.GRV_INIT_MISSING_CALL_CODE
- the callCode
value hasn't been setGruveo.GRV_INIT_INVALID_CALL_CODE
- the callCode
value contains invalid charactersGruveo.GRV_INIT_MISSING_CLIENT_ID
- the clientId
value hasn't been setGruveo.GRV_INIT_OFFLINE
- the device is offline.The methods listed below let you send commands to the SDK.
Gruveo.generateRandomCode():String
Gruveo.isCodeValid(code:String)
code
is a valid room name or Gruveo handle.Gruveo.authorize(token:String)
Gruveo.endCall()
Gruveo.toggleVideo(enable:Boolean)
true
in the enable
parameter to turn the camera on; pass false
to turn it off.Gruveo.switchCamera(useFront:Boolean)
true
in the useFront
parameter to activate the front camera, or false
to activate the rear one.Gruveo.toggleAudio(enable:Boolean)
true
in the enable
parameter to unmute the mic or pass false
to mute it.Gruveo.toggleRecording(enable:Boolean)
true
in the enable
parameter to start call recording or false
to stop it. Recordings done with this method use the default "maximized" layout. Toggling call recording is only available when the call is ongoing. Check out Call Recording for call recording prerequisites and more information.Gruveo.toggleRecording(enable:Boolean, layout:Int)
true
in the enable
parameter to start call recording or false
to stop it. The following layout
values are supported:Gruveo.GRV_LAYOUT_MAXIMIZED
– maximize the currently active speakerGruveo.GRV_LAYOUT_TILED
– display all participants’ pictures in tiles of approximately the same size.Gruveo.toggleRoomLock(enable: Boolean)
true
in the enable
parameter to lock the room or pass false
to unlock it. This functionality is only available when the call is ongoing.Gruveo.isCallActive():Boolean
The Gruveo.EventsListener
interface is used for sending information from the SDK to the app. The interface contains the following functions. RequestToSignApiAuthToken
is called on a background thread, others from the main thread.
fun callInit(videoCall:Boolean, code:String)
videoCall
variable indicates if the call was started as a video or voice-only one. code
contains the room name or handle called.fun requestToSignApiAuthToken(token:String)
token
parameter contains the token value to sign. Please see Authentication for details.fun callEstablished(code:String)
CallInit
is guaranteed to be called before this function.fun callEnd(data:Intent, isInForeground:Boolean)
data
parameter is used for passing extras with call information (see below). isInForeground
indicates if the app was in the foreground when the call ended.fun recordingStateChanged(us:Boolean, them:Boolean)
us
value indicates if we are currently recording the call (true
for recording and false
for not recording). them
indicates if one of the other call participants is recording.fun recordingFilename(filename:String)
filename
parameter contains the filename of the recording.After a call ends, you can retrieve information about it (e.g. call duration) in two different ways:
callEnd(data:Intent, isInForeground:Boolean)
callback function of the Gruveo.EventsListener
interface, which also tells you if the app was in the foreground when the call ended.onActivityResult()
, which will contain the call information only if you provided a requestCode
during the call initialization.Both approaches will return the same extras. onActivityResult()
should be used if you want to use the call information and display it to the user, for example the call duration. Unfortunately, onActivityResult()
is not triggered if the app is in the background as the call ends. If you want a more reliable way (and, for example, to be able to log the extras somewhere), you should be using the onCallEnd()
callback, which is guaranteed to be executed after the call, before onActivityResult()
.
Regardless of the approach, the following call information can be retrieved from data
:
data.getSerializableExtra(Gruveo.GRV_RES_CALL_END_REASON):CallEndReason
Gruveo.BUSY
- the call room is lockedGruveo.HANDLE_BUSY
- the callee is busy with another callGruveo.HANDLE_UNREACHABLE
- the callee is unreachableGruveo.HANDLE_NONEXIST
- the Gruveo handle doesn't existGruveo.FREE_DEMO_ENDED
- the 5-minute call limit has been reached (when using the demo
client ID)Gruveo.ROOM_LIMIT_REACHED
- the room limit of 12 participants has been reachedGruveo.NO_CONNECTION
- lost connectionGruveo.INVALID_CREDENTIALS
- invalid token signature providedGruveo.OTHER_PARTY
- the call ended due to the other party hanging upGruveo.USER
- the call ended due to the user hanging up.data.getStringExtra(Gruveo.GRV_RES_CALL_CODE)
data.getIntExtra(Gruveo.GRV_RES_CALL_DURATION, 0)
0
if the call was not established.data.getIntExtra(Gruveo.GRV_RES_MESSAGES_SENT, 0)
Gruveo.toggleRecording()
method with the layout
parameter.recordingFilename
event.Gruveo.GRV_RES_CALL_ERROR
and CallErrorType
to Gruveo.GRV_RES_CALL_END_REASON
and CallEndReason
, respectively.Gruveo.NONE
value from CallEndReason
.Gruveo.OTHER_PARTY
and Gruveo.USER
values to CallEndReason
.Gruveo.GRV_EXTRA_DISABLE_CHAT
parameter in otherExtras
.