/** Initializes the skylink connection */ private void initializeSkylinkConnection() { if (skylinkConnection == null) { skylinkConnection = SkylinkConnection.getInstance(); // The app_key and app_secret is obtained from the temasys developer console. skylinkConnection.init(APP_KEY, getSkylinkConfig(), this); // Set listeners to receive callbacks when events are triggered skylinkConnection.setRemotePeerListener(this); skylinkConnection.setDataTransferListener(this); skylinkConnection.setLifeCycleListener(this); } }
@Override public void onDestroy() { // close the connection when the fragment is detached, so the streams are not open. if (skylinkConnection != null && connected) { skylinkConnection.disconnectFromRoom(); skylinkConnection.setLifeCycleListener(null); skylinkConnection.setMediaListener(null); skylinkConnection.setRemotePeerListener(null); connected = false; } super.onDestroy(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imgViewer = (ImageView) findViewById(R.id.image_view); projectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE); // Use the device id as the username String deviceId = Settings.Secure.getString( getApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID); // Initialize skylinkConnection and connect to the room initializeSkylinkConnection(); skylinkConnection.connectToRoom(APP_SECRET, ROOM_NAME, deviceId); // Start capture handling thread new Thread() { @Override public void run() { Looper.prepare(); handler = new Handler(); Looper.loop(); } }.start(); }