Log in or register to post comments

Webview integration issue

September 9, 2013 - 6:07am #1

Hi,

I am trying to integrate a webview into the cloud service. I am using the concept explained in the link: http://developer.android.com/guide/webapps/overview.html 

My issue is that the webview will replace the existing camera view when displayed. I want the camera feed displayed with a transparent web view over it so that I can load content to the web view using JavaScript.

Is it technically possible? My aim is to replicate the exact behavior of Layar App.

Thanks,

BP

Webview integration issue

November 21, 2013 - 1:17am #5

My solution is:

---

Dialog dialog        = new Dialog(this);
WebView webview      = new WebView(this);    
WebSettings settings = webview.getSettings();
String databasePath  = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
 
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
 
webview.loadUrl(url);
webview.setWebViewClient(new WebViewClient() {
 
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
 
view.loadUrl(url);
 
return true;
 
}
 
});
 
settings.setJavaScriptEnabled(true);        
settings.setDatabaseEnabled(true);        
settings.setAppCacheEnabled(false);        
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
settings.setDatabasePath(databasePath);
 
dialog.setContentView(webview);     
dialog.show();
---
 
Thanks,
BP

Webview integration issue

November 12, 2013 - 8:54am #4

Hi,

Yes, I was able to implement this using Dialog object.

 

Thanks,

BP

Webview integration issue

October 7, 2013 - 6:33am #3

Are you successfull in implementing a transparent webview?

Webview integration issue

October 3, 2013 - 2:57am #2

Yes , you can! I implemented this feature just yesterday in my Vuforia AR app... :-)

Call the following method during the QCAR camera rendering.

  Dialog dialog = null;

   ...

    private void showOverLay(String urlToOpen){
        
        if (dialog!=null)
            dialog.dismiss();
        
        if (urlToOpen==null)
            return;
        
        dialog = new Dialog(ctx, android.R.style.Theme_Translucent_NoTitleBar);

        dialog.setContentView(R.layout.overlay_view_web);
      
        LinearLayout layout = (LinearLayout) dialog.findViewById(R.id.overlayLayout);
        
        final WebView myWebView = (WebView) dialog.findViewById(R.id.webview);
      

// set the trasparency !

        myWebView.setAlpha(0.8f);
        myWebView.setWebViewClient(new WebViewClient());
        myWebView.loadUrl(urlToOpen);
        myWebView.setBackgroundColor(Color.TRANSPARENT);
        Paint p = new Paint();
        myWebView.setLayerType(WebView.LAYER_TYPE_SOFTWARE, p);
        
       
        /*
        myWebView.setOnLongClickListener(new View.OnLongClickListener() {
        
            @Override
            public boolean onLongClick(View v) {
                
                dialog.dismiss();
                return mContAutofocus;
            }

        });
        */
        
        dialog.show();

    }

 

where layout.overlay_view_web is the following:

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@null"
    android:orientation="vertical"
    android:id="@+id/overlayLayout">
   <WebView  
    android:id="@+id/webview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
/>
</LinearLayout>

Log in or register to post comments