@Override public void onClick(View v) { switch (v.getId()) { case R.id.start_btn: if (makeFbReadable() /* && mCurrentRenderIp != null*/) { NativeAshare.setRotate(mDisplay.getRotation()); // stb ip NativeAshare.shareScreen(mJniCallback, "192.168.43.1"); mOrentationListener = new MyOrientationEventListener(AshareStartActivity.this); mOrentationListener.enable(); } else { Log.d(TAG, "fb open failure!!!"); } break; case R.id.stop_btn: NativeAshare.stopShare(); if (mOrentationListener != null) { mOrentationListener.disable(); } break; default: break; } }
@Override public void onOrientationChanged(int orientation) { // We keep the last known orientation. So if the user first orient // the camera then point the camera to floor or sky, we still have // the correct orientation. if (orientation == ORIENTATION_UNKNOWN) { return; } else { if (mOrientation != mDisplay.getRotation()) { switch (mDisplay.getRotation()) { case Surface.ROTATION_0: mRotationSent2Server = 0; break; case Surface.ROTATION_90: mRotationSent2Server = 90; break; case Surface.ROTATION_180: mRotationSent2Server = 180; break; case Surface.ROTATION_270: mRotationSent2Server = 270; break; default: break; } Log.d( TAG, "onOrientationChanged=" + orientation + " mDisplay.getRotation=" + mDisplay.getRotation()); mOrientation = mDisplay.getRotation(); NativeAshare.setRotate(mRotationSent2Server); } } }