Java tutorial
package com.jio.mhood.services.api.settings; import android.annotation.TargetApi; import android.os.Build; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebSettings.PluginState; import android.webkit.WebView; import com.jio.mhood.services.R; public class LicensesFragment extends Fragment { private static final String URL = "file:///android_asset/licenses.html"; private ViewGroup mParent; private WebView mWebView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); } @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup view = (ViewGroup) inflater.inflate(R.layout.fragment_licenses, container, false); if (mWebView == null) { mWebView = new WebView(view.getContext()); mWebView.setLayoutParams( new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mWebView.setWebChromeClient(new WebChromeClient()); mWebView.setBackgroundColor(0); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setPluginState(PluginState.ON_DEMAND); webSettings.setPluginState(PluginState.ON); webSettings.setBuiltInZoomControls(true); webSettings.setUseWideViewPort(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { webSettings.setDisplayZoomControls(false); } mWebView.loadUrl(URL); } else { mParent.removeView(mWebView); } mParent = view; mParent.addView(mWebView); return mParent; } }