Previously i used SurfaceView, which can be made transparent by the below method. I don't use SurfaceView now. Don't mark it as duplicate. I know how to make SurfaceView Transparent, Now i am trying to migrate my code from SurfaceView to GLSurfaceView . To make screen transparent , i tried the below method :
public void clear() {
Constants.debugLog(TAG,"clear method called ");
Canvas canvas = null;
try {
canvas = getHolder().lockCanvas();
canvas.drawColor(Color.TRANSPARENT);
} catch (Exception e) {
Constants.debugLog(TAG,"clear() 1st try "+e.toString());
} finally {
try {
if (canvas != null) {
getHolder().unlockCanvasAndPost(canvas);
}
} catch (Exception e) {
Constants.debugLog(TAG,"clear() 2nd try "+e.toString());
}
}
}
But it don't work on my custom GLSurfaceView. As GLSurfaceView is a subclass of SurfaceView, it should work on this. It throw the below exceptions
Exception locking surface
java.lang.IllegalArgumentException
at android.view.Surface.nativeLockCanvas(Native Method)
at android.view.Surface.lockCanvas(Surface.java:275)
at android.view.SurfaceView$4.internalLockCanvas(SurfaceView.java:823)
at android.view.SurfaceView$4.lockCanvas(SurfaceView.java:791)
at com.ringid.voicecall.video.VideoCallImageRenderView.clear(VideoCallImageRenderView.java:77)
at com.ringid.voicecall.OutgoingRingCallScreen.stopOwnVideoCall(OutgoingRingCallScreen.java:988)
at com.ringid.voicecall.OutgoingRingCallScreen.decideStart_or_stop_Video(OutgoingRingCallScreen.java:1090)
at com.ringid.voicecall.OutgoingRingCallScreen.onClick(OutgoingRingCallScreen.java:882)
at android.view.View.performClick(View.java:4856)
Any idea about the problem will be helpful to me . Currently i am drawing image on GLSurfaceView from camera. When i stop camera and make the visibility of GLSurfaceView to GONE, it still show the last frame on screen. So i need to make that transparent