Integrate our SDK into your app


Application class

Pass the application context and token to the `LensSDK` in the `onCreate` of the base application.
 



class LensApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        LensSDK.setToken(this, "YOUR_TOKEN")       
    }
}

 

 

MainActivity class

Configure the session related params needed to validate and start the session.

 



LensSDK.setCallbackListener(callbackHandler)
    	.setARMode(true) // To define the mode in which the session should start
    	.addStreamingView(stream_view) // To add the rendering  view to display local and remote view
    	.setUserInfo(UserInfo("User_Name", "User_Mail_ID")) // Used to show the details of the user in session details
   	.startSession(sessionKey = "Session_Key" )  // Session key and SDK token will be validated & `sessionConnectionState` callback will be called with success or error. 

`stream_view` is the view in which the local and remote media will stream.

 

Once the session has been validated successfully, the session can be joined.
 



LensSDK.joinSession() // Joins the successfully validated session

Start the `LensSDK` in the streaming activity and set up all the necessary lifecycle methods as shown below.

 

Note: The lifecycle methods need to be called in the activity where `stream_view` is used.

 



override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    LensSDK.onCreate(this)
}

override fun onPause() {
    super.onPause()
    LensSDK.onPause()
}

override fun onResume() {
    super.onResume()
    LensSDK.onResume()
}

override fun onStart() {
    super.onStart()
    LensSDK.onStart()
}

override fun onStop() {
    super.onStop()
    LensSDK.onStop()
}

override fun onConfigurationChanged(newConfig: Configuration) {
    super.onConfigurationChanged(newConfig)
    LensSDK.onConfigurationChanged(newConfig)
}