am 2503a62b: Merge "Have the MediaProjection sample use the callback." into lmp-mr1-dev
* commit '2503a62bc3dfda20a81d1e762f68981b8963c678': Have the MediaProjection sample use the callback.
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_alignParentBottom="true">
|
android:layout_alignParentBottom="true">
|
||||||
<ToggleButton
|
<ToggleButton
|
||||||
|
android:id="@+id/screen_sharing_toggle"
|
||||||
android:text="@string/screen_sharing_toggle"
|
android:text="@string/screen_sharing_toggle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ public class MediaProjectionDemo extends Activity {
|
|||||||
private VirtualDisplay mVirtualDisplay;
|
private VirtualDisplay mVirtualDisplay;
|
||||||
private Surface mSurface;
|
private Surface mSurface;
|
||||||
private SurfaceView mSurfaceView;
|
private SurfaceView mSurfaceView;
|
||||||
|
private ToggleButton mToggle;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -85,6 +86,8 @@ public class MediaProjectionDemo extends Activity {
|
|||||||
s.setAdapter(arrayAdapter);
|
s.setAdapter(arrayAdapter);
|
||||||
s.setOnItemSelectedListener(new ResolutionSelector());
|
s.setOnItemSelectedListener(new ResolutionSelector());
|
||||||
s.setSelection(0);
|
s.setSelection(0);
|
||||||
|
|
||||||
|
mToggle = (ToggleButton) findViewById(R.id.screen_sharing_toggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -108,6 +111,7 @@ public class MediaProjectionDemo extends Activity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mMediaProjection = mProjectionManager.getMediaProjection(resultCode, data);
|
mMediaProjection = mProjectionManager.getMediaProjection(resultCode, data);
|
||||||
|
mMediaProjection.registerCallback(new MediaProjectionCallback(), null);
|
||||||
mVirtualDisplay = createVirtualDisplay();
|
mVirtualDisplay = createVirtualDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,11 +137,14 @@ public class MediaProjectionDemo extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void stopScreenSharing() {
|
private void stopScreenSharing() {
|
||||||
mScreenSharing = false;
|
if (mToggle.isChecked()) {
|
||||||
if (mVirtualDisplay == null) {
|
mToggle.setChecked(false);
|
||||||
return;
|
}
|
||||||
|
mScreenSharing = false;
|
||||||
|
if (mVirtualDisplay != null) {
|
||||||
|
mVirtualDisplay.release();
|
||||||
|
mVirtualDisplay = null;
|
||||||
}
|
}
|
||||||
mVirtualDisplay.release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private VirtualDisplay createVirtualDisplay() {
|
private VirtualDisplay createVirtualDisplay() {
|
||||||
|
|||||||
Reference in New Issue
Block a user