SurfaceView getHolder - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for SurfaceView getHolder method.

This code example shows how to use the following methods:getHolder, setLayoutParams
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getHolder, setFocusable, setFocusableInTouchMode, setOnTouchListener
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		mPreview = new SurfaceView(this);
		setContentView(mPreview);
		 
		init(); 
		 
		initViews(); 
	} 
	 
	private void initViews() { 
		mPreview.setFocusable(true);
		mPreview.setFocusableInTouchMode(true);
		mPreview.setOnTouchListener(this);
		 
		/* 得到SurfaceHolder对象 */ 
		mHolder = mPreview.getHolder();

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getHolder
 
        mCamera = camera;
 
        // Install a SurfaceHolder.Callback so we get notified when the 
        // underlying surface is created and destroyed. 
        mHolder = mSurfaceView.getHolder();
        mHolder.addCallback(this);
        mHolder.setSizeFromLayout();
        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    } 
     
    public void stopPreview() { 
        Logger.T(TAG, "stopPreview");
        if (mCamera != null) {
            mCamera.stopPreview();
            mCamera = null;
        } else { 
            Logger.T(TAG, "No camera to stop preview");
        } 
    } 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getHolder
	private FeatureStreamer fs;
 
	FeatureStreamingCameraPreview(Context context, FeatureStreamer fs) {
		super(context);
		this.fs = fs;
		mSurfaceView = new SurfaceView(context);
		addView(mSurfaceView);
 
		mHolder = mSurfaceView.getHolder();
		mHolder.addCallback(this);
		mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
	} 
 
	public void updateAccelerometerFeatures(float[] features) {
		synchronized (this) {
		  accelerometerFeatures = features;
		} 
	} 
	 
	public void setCamera(Camera camera) {
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getHolder
 
    public CameraPreview(Context context, Camera camera, SurfaceView filtered) {
        super(context);
        mCamera = camera;
        mFiltered = filtered;
        mFiltered.getHolder().setFormat(ImageFormat.YV12);
 
        previewData = new byte[640*480 + 320*240*2];
 
        // Install a SurfaceHolder.Callback so we get notified when the 
        // underlying surface is created and destroyed. 
        mHolder = getHolder();
        mHolder.addCallback(this);
 
    } 
 
    public void onPreviewFrame(byte[] data, Camera camera) {
        if (mFiltered.getHolder().getSurface().isValid()) {
            processFrame(data, mFiltered.getHolder().getSurface());
            /* 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getHolder
	public CameraPreview(Context context, Camera.PreviewCallback previewCallback, boolean hidden ) {
		super(context);
		this.previewCallback = previewCallback;
		this.hidden = hidden;
 
		mSurfaceView = new SurfaceView(context);
		addView(mSurfaceView);
 
		// Install a SurfaceHolder.Callback so we get notified when the 
		// underlying surface is created and destroyed. 
		mHolder = mSurfaceView.getHolder();
		mHolder.addCallback(this);
		// deprecated setting, but required on Android versions prior to 3.0 
		mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
	} 
 
	public void setCamera(Camera camera) {
		mCamera = camera;
		if (mCamera != null) {
			requestLayout();
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getHolder
    private List<Size> mSupportedPreviewSizes;
    private SurfaceView mSurfaceView;
     
    public Preview(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        mSurfaceView = new SurfaceView(context, attributeSet);
        addView(mSurfaceView);
        // Install a SurfaceHolder.Callback so we get notified when the 
        // underlying surface is created and destroyed. 
        mHolder = mSurfaceView.getHolder();
        mHolder.addCallback(this);
        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    } 
     
    public void setCamera(Camera camera) {
        mCamera = camera;
        if (mCamera != null) {
            mSupportedPreviewSizes = mCamera.getParameters().getSupportedPreviewSizes();
            requestLayout();
        } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setEGLConfigChooser, setRenderer, getHolder
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        // Create our Preview view and set it as the content of our 
        // Activity 
        mGLSurfaceView = new GLSurfaceView(this);
        // We want an 8888 pixel format because that's required for 
        // a translucent window. 
        // And we want a depth buffer. 
        mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
        // Tell the cube renderer that we want to render a translucent version 
        // of the cube: 
        mGLSurfaceView.setRenderer(new CubeRenderer(true));
        // Use a surface format with an Alpha channel: 
        mGLSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
        setContentView(mGLSurfaceView);
    } 
 
    @Override 
    protected void onResume() { 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getHolder
        System.loadLibrary("sampleplugin");
    } 
     
    public View getEmbeddedView(final int npp, Context context) {
         
        final SurfaceView view = new SurfaceView(context);
 
        /* You can do all sorts of interesting operations on the surface view 
         * here. We illustrate a few of the important operations below. 
         */ 
         
        //TODO get pixel format from the subplugin (via jni) 
        view.getHolder().setFormat(PixelFormat.RGBA_8888);
        view.getHolder().addCallback(new Callback() {
 
            public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
                nativeSurfaceChanged(npp, format, width, height);
            } 
 
            public void surfaceCreated(SurfaceHolder holder) {
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setEGLConfigChooser, setRenderer, getHolder
     
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         
        glView = new GLSurfaceView(this);
    	glView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
		glView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    	glView.setRenderer(this);
        setContentView(glView);
         
        assetMgr = getResources().getAssets();
 
        handler = new ColladaHandler();
    } 
     
    @Override 
    protected void onResume(){ 
    	super.onResume(); 
 
7
CodeRank
Experience pair programming with AI  Get Codota for Java

Related SurfaceView getHolder Questions & Answers:

getHolder Method Overview
Return the SurfaceHolder providing access and control over this SurfaceView's underlying surface.
See Code Examples for other Android SurfaceView Methods: