AR interface in Android using phoneGap

Since 6 months ago we have evaluated the possibility to implement a new AR interface (based in our project ARviewer) using phoneGap. phoneGap is a mobile framework based in HTML5/JS that allow execute the same source code HTML5 in differents mobile platforms (iphone, android, blackberry). It seem a good way to create portable source code. Since 3 years ago I work in this project with Raúl Román, a crack coder!!

Currently using phoneGap is not possible obtain the stream camera in the webView widget. So, this part of the source code must be developed in the native platform. We find another problem. We could not put the webview transparent so it would look the camera in the background, and paint objects on top with HTML. In this case, we asked for this to David A. Lareo (Bcultura) and Julio Rabadán (Somms.net) and gave us some very interesting clues about this problem.

The solution is implemented in the source code that you can see below. It’s necessary that our main view (R.layout.main) is the main view, for this we do ‘setContentView’ and later we add the main view of ‘DroidGap’ using ‘addview’ and ‘getParent’. Once we have our view mixed with phonegap main view, we set the backgroundColor transparent.

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.init();
        super.loadUrl("file:///android_asset/www/index.html");

        setContentView(R.layout.main);
        RelativeLayout view = (RelativeLayout)
                              findViewById(R.id.main_container);

        // appView is the WebView object
        View html = (View)appView.getParent();
        html.setBackgroundColor(Color.TRANSPARENT);
        view.addView (html,
                      new LayoutParams(LayoutParams.FILL_PARENT,
                      LayoutParams.FILL_PARENT));

        appView.setBackgroundColor(Color.TRANSPARENT);
    }

Currently, we have started this project so I will post the full source code in this blog

facebooktwittergoogle_pluslinkedinmailby feather
This entry was posted in android, androidfloss, codigo, libresoft. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *