It is possible to punch through a webview with a custom view.  Make sure 
Internet and Camera permissions are set in the manifest.

The following will make a circular hole in the web page through which the 
camera shows.

- rich

package com.optiv.cameraweb;

import android.content.Context;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.util.AttributeSet;
import android.view.View;
public class WebPunchThru extends View {


    // This constructor is used when the class is built from an XML 
resource.
    public WebPunchThru(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);        
        Path path = new Path();
        path.addCircle(200.0f, 200.0f, 100.0f, Path.Direction.CW);
         canvas.clipPath(path);
        canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); // 
transparent windows


      }
    }

package com.optiv.cameraweb;
import java.io.IOException;

import android.app.Activity;
import android.hardware.Camera;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.webkit.WebView;
import android.webkit.WebViewClient;


public class CameraWebActivity extends Activity implements 
 SurfaceHolder.Callback{
    WebView mWebView;
    WebPunchThru webPunchThru;
    SurfaceView surfaceView;
    SurfaceHolder surfaceHolder;
    Camera camera;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        surfaceView = (SurfaceView) findViewById(R.id.SurfaceView01);
        surfaceHolder = surfaceView.getHolder();
        surfaceHolder.addCallback(this);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        
        
        mWebView = (WebView) findViewById(R.id.WebView01);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.loadUrl("http://www.google.com";);
        webPunchThru = (WebPunchThru) findViewById(R.id.Punch01);
        mWebView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String 
url) {
                mWebView.loadUrl(url);
                return true;
            }
        });
    }
    @Override
    public void onResume(){
        camera = Camera.open();
        super.onResume();
    }
    @Override
    public void onPause(){
        camera.stopPreview();
        camera.release();
        super.onPause();
    }

    public void surfaceChanged(SurfaceHolder holder, int format, int width, 
int height) {
        try {
            camera.setPreviewDisplay(holder);
        } catch (IOException e) {
            e.printStackTrace();
        }
        camera.startPreview();
         
    }
 
    public void surfaceCreated(SurfaceHolder holder) {
        try {
            camera.setPreviewDisplay(holder);
        } catch (IOException e) {
            e.printStackTrace();
        }
        camera.startPreview();
        
    }
  
    public void surfaceDestroyed(SurfaceHolder holder) {
        camera.stopPreview();
        
    }
}

. 
>>
>> <?xml version="1.0" encoding="utf-8"?>
>
> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android";
>
>     android:id="@+id/FrameLayout0x"
>
>     android:layout_width="fill_parent"
>
>     android:layout_height="fill_parent" >
>
>
>>     <SurfaceView
>
>         android:id="@+id/SurfaceView01"
>
>         android:layout_width="fill_parent"
>
>         android:layout_height="fill_parent" >
>
>     </SurfaceView>
>
>
>>       <WebView
>
>
>>   android:id="@+id/WebView01"
>
>   android:layout_width="fill_parent"
>
>   android:layout_height="fill_parent"
>
>   android:background= "#00000000" />
>
>     <RelativeLayout
>
>         android:id="@+id/RelativeLayout01"
>
>         android:layout_width="fill_parent"
>
>         android:layout_height="fill_parent" >
>
>
>>        <com.optiv.cameraweb.WebPunchThru
>
>             android:id="@+id/Punch01"
>
>             android:layout_width="fill_parent"
>
>             android:layout_height="fill_parent" /> 
>
>     </RelativeLayout>
>
>
>>
>> </FrameLayout>
>
> > --------------------------------------------------------

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to