5

I'm working on a project that needs to manage requests(html/javascript) and many more other things. I Used Chromiumembedded for windows. Now I need something like that for android.

I've searched about android programming and spent some time on Phonegap. As I know it opens a webview and have some javascript API for some device features like camera. So Phonegap is not going to help me.

I wonder if there is any way to embed Chrome or any other browser that can be embedded in an android app?

Clifford
  • 88,407
  • 13
  • 85
  • 165
Ata Iravani
  • 2,146
  • 7
  • 29
  • 40
  • 2
    What's wrong with embedding a [WebView](http://developer.android.com/reference/android/webkit/WebView.html)? – assylias Jan 26 '13 at 08:52
  • Webview is the answer. It has got enormous capability. You should experiment with it. – VendettaDroid Jan 26 '13 at 09:10
  • As far as I understand, chromiumembedded is a capability to your desktop application to have a browser, so developers won't get to develop their own browser into that app. WebView in Android is the equal to chromiumembedded in PC. – Zyoo Jan 26 '13 at 09:13
  • A great lake is WebView does not support **queryString**. example: `webView.loadUrl("file:///android_asset/foo.html?a=1");` shows error. But using phonegap solves this problem. – Ata Iravani Jan 26 '13 at 09:39
  • 1
    Get rid of the query parameters. Find another way to pass the data into the app, such as by injecting an object via `addJavaScriptInterface()` which the Web page uses to pull data from. – CommonsWare Jan 26 '13 at 13:13

3 Answers3

6

Android has a WebView component that is basically a browser. You can place it anywhere in your application and you can enable JavaScript that is disabled by default. Supports HTML 5. I use it in production and fully recommend.

Unfortunately the 3.x versions have a bug not supporting string query that may be present inside URLs of some pages. In the bug website this issue shows as closed and fixed. I was even not aware about it as we use 4.1.0 for everything. The bug is already fixed with that release. For earlier versions, some workarounds are available here.

Audrius Meškauskas
  • 20,936
  • 12
  • 75
  • 93
0

Try android.webkit.WebView it's the equivalent of the iOS's UIWebView

  • Thanks for your participation, please red the [Comment above](http://stackoverflow.com/questions/14535346/are-there-any-ways-to-embed-a-browser-in-android-app#comment20271666_14535346) – Ata Iravani Jan 26 '13 at 12:17
0

Use android.webkit.WebView

Set the view, for example:

WebView mywebview = (WebView) findViewById(R.id.webview);

and load the url of application:

mywebview.loadUrl("http://www.example.com");

or

mywebview.loadUrl("file:///android_asset/html_no_copy/test.html");

and for enable javascript in your application, set:

WebSettings webSettings = mywebview.getSettings();
webSettings.setBuiltInZoomControls(true);
webSettings.setJavaScriptEnabled(true);

Try and read the documentation: http://developer.android.com/reference/android/webkit/WebView.html

  • I think should read the [comment Above](http://stackoverflow.com/questions/14535346/are-there-any-ways-to-embed-a-browser-in-android-app#comment20271666_14535346), too – Ata Iravani Jan 26 '13 at 10:20