am e9860761: am 2503a62b: Merge "Have the MediaProjection sample use the callback." into lmp-mr1-dev
* commit 'e98607612927716a2b3730702f056528d5fd6b29': Have the MediaProjection sample use the callback.
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
android:orientation="horizontal"
|
||||
android:layout_alignParentBottom="true">
|
||||
<ToggleButton
|
||||
android:id="@+id/screen_sharing_toggle"
|
||||
android:text="@string/screen_sharing_toggle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@@ -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