Start a new topic

captureScreen not working

captureScreen not working


I am using captureScreen feature but it is not working. captureScreen function is loading but camera is not capturing anything. No errors in my console also I am working with Phonegap.

My Html:

 <a href="javascript: World.captureScreen()">Snapshot</a>

Javascript:

captureScreen: function captureScreenFn() {

document.location = "architectsdk://button?action=captureScreen";

},

 

Hi Salman,

Since the actual screen capture is implemented on the native side, have you implemented the following in Java?

                // pressed snapshot button. check if host is button to fetch e.g. 'architectsdk://button?action=captureScreen', you may add more checks if more buttons are used inside AR scene
                else if ("button".equalsIgnoreCase(invokedUri.getHost())) {
                    SampleCamActivity.this.architectView.captureScreen(ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW, new CaptureScreenCallback() {
                        
                        @Override
                        public void onScreenCaptured(final Bitmap screenCapture) {
                            if ( ContextCompat.checkSelfPermission(SampleCamActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED ) {
                                SampleCamActivity.this.screenCapture = screenCapture;
                                ActivityCompat.requestPermissions(SampleCamActivity.this, new String{Manifest.permission.WRITE_EXTERNAL_STORAGE}, WIKITUDE_PERMISSIONS_REQUEST_EXTERNAL_STORAGE);
                            } else {
                                SampleCamActivity.this.saveScreenCaptureToExternalStorage(screenCapture);
                            }
                        }
                    });
                }

 

You can find the implementation in our official Examples app shipped along with the SDK. This code segment is in the SampleCamActivity.java file.

 

Thank you for the reply. Where do i need to put this code in java? Do i need to put it in WikitudePlugin.java? I am not aware to java code very much. Can you provide an example?  
Login or Signup to post a comment