HTML wrapping in an Android app

I have an existing site (social in nature) and it already has a mobile web version, so what I basically want to do is wrap this view in an Android application and maybe add a nice splash screen to it. In fact, this is a "proprietary" browser window.

Any advice would be appreciated.

+7
source share
2 answers

You will need two activities

  • Screensaver (use the timer and after x seconds proceed to the next step)
  • the main

In the main action, you will need to set the layout with webView in your layout, so something like:

<?xml version="1.0" encoding="utf-8"?> <WebView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="fill_parent" /> 

and code:

 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mWebView = (WebView) findViewById(R.id.webview); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.loadUrl("http://www.google.com"); } 

and permissions:

 <uses-permission android:name="android.permission.INTERNET" /> 

in the manifest file.

If you want to disable the title bar, you also need to add:

 <activity android:name=".Main" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar"> 

Read the docs for more help! A Google example for this is accurate and I refer to http://developer.android.com/resources/tutorials/views/hello-webview.html

+11
source

There are also several frameworks that wrap HTML5 inside your own application and give you access to the API.

Telephony is the most famous http://phonegap.com/

+3
source

All Articles