Best code examples for Android TextureView class (android.view.TextureView)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android TextureView class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android TextureView examples from Open Source projects
This code example shows how to use the following methods: setSurfaceTextureListener
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        FrameLayout content = new FrameLayout(this);
 
        mTextureView = new TextureView(this);
        mTextureView.setSurfaceTextureListener(this);
 
        Button button = new Button(this);
        button.setText("Copy bitmap to /sdcard/textureview.png");
        button.setOnClickListener(new View.OnClickListener() {
            @Override 
            public void onClick(View v) {
                Bitmap b = mTextureView.getBitmap();
                try { 
                    FileOutputStream out = new FileOutputStream(
                            Environment.getExternalStorageDirectory() + "/textureview.png");
                    try { 
                        b.compress(Bitmap.CompressFormat.PNG, 100, out);
                    } finally { 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setOpaque, setSurfaceTextureListener
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        FrameLayout content = new FrameLayout(this);
 
        mTextureView = new TextureView(this);
        mTextureView.setSurfaceTextureListener(this);
        mTextureView.setOpaque(false);
 
        content.addView(mTextureView, new FrameLayout.LayoutParams(500, 500, Gravity.CENTER));
        setContentView(content);
    } 
 
    @Override 
    public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
        mThread = new RenderingThread(mTextureView);
        mThread.start();
    } 
 
    @Override 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setSurfaceTextureListener, setOnClickListener
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        mContent = new FrameLayout(this);
 
        mTextureView = new TextureView(this);
        mTextureView.setSurfaceTextureListener(this);
        mTextureView.setOnClickListener(new View.OnClickListener() {
            @Override 
            public void onClick(View v) {
                Bitmap b = mTextureView.getBitmap(800, 800);
                BufferedOutputStream out = null;
                try { 
                    File dump = new File(Environment.getExternalStorageDirectory(), "out.png");
                    out = new BufferedOutputStream(new FileOutputStream(dump));
                    b.compress(Bitmap.CompressFormat.PNG, 100, out);
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } finally { 
                    if (out != null) try {
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setSurfaceTextureListener
  private TextureView widget=null;
  private SurfaceTexture surface=null;
 
  TexturePreviewStrategy(CameraView cameraView) {
    this.cameraView=cameraView;
    widget=new TextureView(cameraView.getContext());
    widget.setSurfaceTextureListener(this);
  } 
 
  @Override 
  public void onSurfaceTextureAvailable(SurfaceTexture surface,
                                        int width, int height) {
    this.surface=surface;
 
    cameraView.previewCreated();
    cameraView.initPreview(width, height);
  } 
 
  @Override 
  public void onSurfaceTextureSizeChanged(SurfaceTexture surface,
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setSurfaceTextureListener, setOnClickListener
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        mTextureView = new TextureView(this);
        mTextureView.setSurfaceTextureListener(this);
        mTextureView.setOnClickListener(new View.OnClickListener() {
            @Override 
            public void onClick(View v) {
                Bitmap b = mTextureView.getBitmap(800, 800);
                BufferedOutputStream out = null;
                try { 
                    File dump = new File(Environment.getExternalStorageDirectory(), "out.png");
                    out = new BufferedOutputStream(new FileOutputStream(dump));
                    b.compress(Bitmap.CompressFormat.PNG, 100, out);
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } finally { 
                    if (out != null) try {
Full Snippet Info
7
CodeRank
Related Android TextureView Questions & Answers:
See Code Examples for Android TextureView Methods: