Announcements

Shape the future of your TeamViewer product with our Product Team. Click here to join!

Posted by alecrugar
Henagon

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?

 

9 Replies
9 Replies
Posted by MitjaHenner
Digon

Re: Android SDK integration

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) {
}

 

Posted by alecrugar
Henagon

Re: Android SDK integration

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!  

Posted by MitjaHenner
Digon

Re: Android SDK integration

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.

Posted by alecrugar
Henagon

Re: Android SDK integration

Alright thanks a lot :)

Posted by sscp
Henagon

Re: Android SDK integration

Where can i found the ?
SDK_TOKEN = ""
CONFIGURATION_ID = ""
Posted by MitjaHenner
Digon

Re: Android SDK integration

I think you can generate them in the Management Console: https://login.teamviewer.com/LogOn

Posted by sscp
Henagon

Re: Android SDK integration

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?

Posted by sscp
Henagon

Re: Android SDK integration

can i have get any sample code or documetation

Posted by MitjaHenner
Digon

Re: Android SDK integration

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()
    }
}