Have the MediaProjection sample use the callback.
Bug: 18393320 Change-Id: I482ed9cde5444d62a5486f4ca91e3dc6b441e673
This commit is contained in:
@@ -64,6 +64,7 @@ public class MediaProjectionDemo extends Activity {
|
||||
private VirtualDisplay mVirtualDisplay;
|
||||
private Surface mSurface;
|
||||
private SurfaceView mSurfaceView;
|
||||
private ToggleButton mToggle;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -85,6 +86,8 @@ public class MediaProjectionDemo extends Activity {
|
||||
s.setAdapter(arrayAdapter);
|
||||
s.setOnItemSelectedListener(new ResolutionSelector());
|
||||
s.setSelection(0);
|
||||
|
||||
mToggle = (ToggleButton) findViewById(R.id.screen_sharing_toggle);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,6 +111,7 @@ public class MediaProjectionDemo extends Activity {
|
||||
return;
|
||||
}
|
||||
mMediaProjection = mProjectionManager.getMediaProjection(resultCode, data);
|
||||
mMediaProjection.registerCallback(new MediaProjectionCallback(), null);
|
||||
mVirtualDisplay = createVirtualDisplay();
|
||||
}
|
||||
|
||||
@@ -133,11 +137,14 @@ public class MediaProjectionDemo extends Activity {
|
||||
}
|
||||
|
||||
private void stopScreenSharing() {
|
||||
mScreenSharing = false;
|
||||
if (mVirtualDisplay == null) {
|
||||
return;
|
||||
if (mToggle.isChecked()) {
|
||||
mToggle.setChecked(false);
|
||||
}
|
||||
mScreenSharing = false;
|
||||
if (mVirtualDisplay != null) {
|
||||
mVirtualDisplay.release();
|
||||
mVirtualDisplay = null;
|
||||
}
|
||||
mVirtualDisplay.release();
|
||||
}
|
||||
|
||||
private VirtualDisplay createVirtualDisplay() {
|
||||
|
||||
Reference in New Issue
Block a user