@SuppressLint("NewApi") @Override public void onClick(View v) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mMediaProjectionManager = (MediaProjectionManager) getApplicationContext() .getSystemService(MEDIA_PROJECTION_SERVICE); startActivityForResult(mMediaProjectionManager .createScreenCaptureIntent(), REQUEST_MEDIA_PROJECTION); } } });
@SuppressLint("NewApi") private void setupMediaProjection() { mMediaProjection = mMediaProjectionManager.getMediaProjection( MainActivity.mResultCode, MainActivity.mResultData); }
public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.v(TAG,"onActivityResult"); if(requestCode!=CAPTURE_CODE){ Log.e(TAG,"onActivityResult : requestCode!=CAPTURE_CODE"); return; } if (resultCode != RESULT_OK) { Log.e(TAG,"onActivityResult : resultCode != RESULT_OK"); mMediaProjectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE); startActivityForResult(mMediaProjectionManager.createScreenCaptureIntent(), CAPTURE_CODE); } mMediaProjection = mMediaProjectionManager.getMediaProjection(resultCode,data); session.setMediaProjection(mMediaProjection); InitCameraView(); } private void AskForPermission(){
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mgr=(MediaProjectionManager)getSystemService(MEDIA_PROJECTION_SERVICE); startActivityForResult(mgr.createScreenCaptureIntent(), REQUEST_SCREENSHOT); }
synchronized private void startRecorder() { if (session==null) { MediaProjectionManager mgr= (MediaProjectionManager)getSystemService(MEDIA_PROJECTION_SERVICE); MediaProjection projection= mgr.getMediaProjection(resultCode, resultData); session= new RecordingSession(this, new RecordingConfig(this), projection); session.start(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mgr=(MediaProjectionManager)getSystemService(MEDIA_PROJECTION_SERVICE); startActivityForResult(mgr.createScreenCaptureIntent(), REQUEST_SCREENCAST); }
private void startCapture() { projection=mgr.getMediaProjection(resultCode, resultData); it=new ImageTransmogrifier(this); MediaProjection.Callback cb=new MediaProjection.Callback() { @Override public void onStop() { vdisplay.release(); } }; vdisplay=projection.createVirtualDisplay("andshooter", it.getWidth(), it.getHeight(), getResources().getDisplayMetrics().densityDpi, VIRT_DISPLAY_FLAGS, it.getSurface(), null, handler); projection.registerCallback(cb, handler); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) protected void requestRecording() { if(!SopCastUtils.isOverLOLLIPOP()) { SopCastLog.d(TAG, "Device don't support screen recording."); return; } mMediaProjectionManage = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE); Intent captureIntent = mMediaProjectionManage.createScreenCaptureIntent(); startActivityForResult(captureIntent, RECORD_REQUEST_CODE); }
@Override public void start() { mEncoder = new ScreenRecordEncoder(mVideoConfiguration); Surface surface = mEncoder.getSurface(); mEncoder.start(); mEncoder.setOnVideoEncodeListener(mListener); mMediaProjection = mManager.getMediaProjection(resultCode, resultData); int width = VideoMediaCodec.getVideoSize(mVideoConfiguration.width); int height = VideoMediaCodec.getVideoSize(mVideoConfiguration.height); mVirtualDisplay = mMediaProjection.createVirtualDisplay("ScreenRecoder", width, height, 1, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, surface, null, null); }
static void requestStart(ActivityResults activityResults, int requestCode) { activityResults.startActivityForResult(projectionManager.createScreenCaptureIntent(), requestCode); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void onReceive(Context context, Intent intent) { unregisterRequestCaptureReceiver(); int resultCode = intent.getIntExtra(RequestCaptureActivity.RESULT_EXTRA_CODE, Activity.RESULT_CANCELED); Intent data = intent.getParcelableExtra(RequestCaptureActivity.RESULT_EXTRA_DATA); final MediaProjection mediaProjection = projectionManager.getMediaProjection(resultCode, data); if (mediaProjection == null) { captureCanvasScreenshot(); return; } if (intent.getBooleanExtra(RequestCaptureActivity.RESULT_EXTRA_PROMPT_SHOWN, true)) { // Delay capture until after the permission dialog is gone. postDelayed(new Runnable() { @Override public void run() { captureNativeScreenshot(mediaProjection); } }, 500); } else { captureNativeScreenshot(mediaProjection); } } };
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void requestCapture() { MediaProjectionManager projectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE); Intent intent = projectionManager.createScreenCaptureIntent(); requestStartTime = System.currentTimeMillis(); startActivityForResult(intent, REQUEST_CODE); }
static void start(int resultCode, Intent data) { mediaProjectionCallback = new MediaProjectionCallback(); mediaProjection = projectionManager.getMediaProjection(resultCode, data); mediaProjection.registerCallback(mediaProjectionCallback, null); virtualDisplay = createVirtualDisplay(); mediaRecorder.start(); setRecording(true); }
/** * Create Intent used to init screen capture with startActivityForResult. * * @return intent to startActivityForResult. */ public Intent sendIntent() { return mediaProjectionManager.createScreenCaptureIntent(); }
private void setUpMediaProjection() { mMediaProjection = mMediaProjectionManager.getMediaProjection(mResultCode, mResultData); }
/****************************************** UI Widget Callbacks *******************************/ private void startProjection() { startActivityForResult(mProjectionManager.createScreenCaptureIntent(), REQUEST_CODE); }
private void setUpMediaProjection() { mMediaProjection = mMediaProjectionManager.getMediaProjection(mResultCode, mResultData); }
private void startCaptureScreen() { if (stateResultCode != 0 && stateResultData != null) { startService(); } else { Log.d(TAG, "Requesting confirmation"); startActivityForResult( mediaProjectionManager.createScreenCaptureIntent(), ACTIVITY_RESULT_REQUEST_MEDIA_PROJECTION); } }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void setUpMediaProjection(int resultCode, Intent data) { if (mMediaProjection != null) return; MediaProjectionManager mMediaProjectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE); mMediaProjection = mMediaProjectionManager.getMediaProjection(resultCode, data); }
private void startCaptureScreen() { if (mResultCode != 0 && mResultData != null) { startService(); } else { Log.d(TAG, "Requesting confirmation"); // This initiates a prompt dialog for the user to confirm screen projection. startActivityForResult( mMediaProjectionManager.createScreenCaptureIntent(), REQUEST_MEDIA_PROJECTION); } }