Android SDK integration
is there any tutorial covering this topic?
I've downloaded the SDK for Android Studio and read the README.md file.
I added the ScreenSharingSDK.aar file to my project and modifies the gradle files.
Now I want to implement the screen sharing and remote control features, but the documentation link is down
For a complete tutorial, please refer to the [Android tutorial]
(http://integrate.teamviewer.com/develop/screen-sharing-sdk/android-tutorial) on the
TeamViewer Integrations Website.
Any ideas?
Comments
-
The SDK is not really useable right now.
It only works with targetSdk 25 and below and right now you can only release apps with 26+ and in a few month only update apps with 26+.
Only have Kotlin files but maybe it helps:
Implement the interface in your Activity and you should be able to start the Session.
class ScreenSharing {
private val SDK_TOKEN = ""
private val CONFIGURATION_ID = ""
private var runningStateListener: RunningStateListener? = null
var isSessionRunning = false
private set(isRunning) {
field = isRunning
runningStateListener?.onRunningStateChange(isRunning)
}
fun setRunningStateListener(listener: RunningStateListener?) {
runningStateListener = listener
}
fun startSession(activity: Activity, serviceCaseName: String, serviceCaseDescription: String) {
try {
val configuration = createConfiguration(serviceCaseName, serviceCaseDescription)
TVSessionFactory.createTVSession(activity, SDK_TOKEN, createSessionCreationCallback(this, configuration))
} catch (e: IllegalArgumentException) {
} catch (e: IllegalStateException) {
}
}
private fun createConfiguration(serviceCaseName: String, serviceCaseDescription: String): TVSessionConfiguration {
return TVSessionConfiguration.Builder(TVConfigurationID(CONFIGURATION_ID))
.setServiceCaseName(serviceCaseName)
.setServiceCaseDescription(serviceCaseDescription)
.build()
}
private fun createSessionCreationCallback(
wrapper: ScreenSharing, configuration: TVSessionConfiguration): TVSessionCreationCallback {
return object : TVSessionCreationCallback {
override fun onTVSessionCreationSuccess(session: TVSession) {
session.setTVSessionCallback(createSessionCallback(wrapper))
session.start(configuration)
wrapper.isSessionRunning = true
}
override fun onTVSessionCreationFailed(error: TVCreationError) {
}
}
}
private fun createSessionCallback(wrapper: ScreenSharing): TVSessionCallback {
return object : TVSessionCallback {
override fun onTVSessionEnd() {
wrapper.isSessionRunning = false
}
override fun onTVSessionError(error: TVSessionError) {
}
}
}
interface RunningStateListener {
fun onRunningStateChange(isRunning: Boolean)
}
companion object {
val instance = ScreenSharing()
}
}Main:
class MainActivity : AppCompatActivity(), ScreenSharing.RunningStateListener
override fun onResume() {
super.onResume()
ScreenSharing.instance.setRunningStateListener(this)
}
override fun onPause() {
super.onPause()
ScreenSharing.instance.setRunningStateListener(null)
}
private fun startTeamViewerSession() {
ScreenSharing.instance.startSession(this, "Test", "Test")
}override fun onRunningStateChange(isRunning: Boolean) {
}0 -
Thanks a lot MitjaHenner, I really appreciate your help. Do you know where I can find the information that the SDK only works with targetSdk 25 and below? Is there any official announcement? Thanks!
0 -
Nope, I found out when I tried to use the SDK and couldn't get it to work for hours.
Probably because of the "new" permissions.
0 -
Alright thanks a lot
0 -
Where can i found the ?
SDK_TOKEN = ""
CONFIGURATION_ID = ""0 -
I think you can generate them in the Management Console: https://login.teamviewer.com/LogOn
0 -
I got only tokan from consol after created App with android sdk, but where can i found the CONFIGURATION_ID or how can i generate it?
0 -
can i have get any sample code or documetation
0 -
Go to deploy on the management console:
https://login.teamviewer.com/nav/deploy
and click the "add quicksupport" button the Id you get after creating the quicksupport is your configurationId.
Download the SDK and in Android Studio: File -> New Module -> Import JAR/.AAR Package to import it.
In your build.gradle (app not project) add the dependency and remember to use targetSdkVersion 25 or lower.
dependencies {
implementation project(": ScreenSharingSDK")
}Example implementation (Kotlin again):
class MainActivity : AppCompatActivity(), ScreenSharing.RunningStateListener {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
button.setOnClickListener { startTeamViewerSession() }
}
override fun onResume() {
super.onResume()
ScreenSharing.instance.setRunningStateListener(this)
}
override fun onPause() {
super.onPause()
ScreenSharing.instance.setRunningStateListener(null)
}
private fun startTeamViewerSession() {
ScreenSharing.instance.startSession(this, "Title", "Description")
}
override fun onRunningStateChange(isRunning: Boolean) {
}
}class ScreenSharing {
private val SDK_TOKEN = ""
private val CONFIGURATION_ID = ""
private var runningStateListener: RunningStateListener? = null
var isSessionRunning = false
private set(isRunning) {
field = isRunning
runningStateListener?.onRunningStateChange(isRunning)
}
fun setRunningStateListener(listener: RunningStateListener?) {
runningStateListener = listener
}
fun startSession(activity: Activity, serviceCaseName: String, serviceCaseDescription: String) {
try {
val configuration = createConfiguration(serviceCaseName, serviceCaseDescription)
TVSessionFactory.createTVSession(activity, SDK_TOKEN, createSessionCreationCallback(this, configuration))
} catch (e: IllegalArgumentException) {
} catch (e: IllegalStateException) {
}
}
private fun createConfiguration(serviceCaseName: String, serviceCaseDescription: String): TVSessionConfiguration {
return TVSessionConfiguration.Builder(TVConfigurationID(CONFIGURATION_ID))
.setServiceCaseName(serviceCaseName)
.setServiceCaseDescription(serviceCaseDescription)
.build()
}
private fun createSessionCreationCallback(
wrapper: ScreenSharing, configuration: TVSessionConfiguration): TVSessionCreationCallback {
return object : TVSessionCreationCallback {
override fun onTVSessionCreationSuccess(session: TVSession) {
session.setTVSessionCallback(createSessionCallback(wrapper))
session.start(configuration)
wrapper.isSessionRunning = true
}
override fun onTVSessionCreationFailed(error: TVCreationError) {
}
}
}
private fun createSessionCallback(wrapper: ScreenSharing): TVSessionCallback {
return object : TVSessionCallback {
override fun onTVSessionEnd() {
wrapper.isSessionRunning = false
}
override fun onTVSessionError(error: TVSessionError) {
}
}
}
interface RunningStateListener {
fun onRunningStateChange(isRunning: Boolean)
}
companion object {
val instance = ScreenSharing()
}
}1 -
TVSessionConfiguration
I am getting error in android studio
0