I have an Android application with 4 tabs and I am trying to load a different webview into each tab. One of the webviews contains an audio stream. I am having 2 problems:
The Audio stream page will not load. The fragment loads to a blank white page for the audio stream webview.
ListenLiveFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment` View v= inflater.inflate(R.layout.fragment_listen_live, container, false); web_v=(WebView)v.findViewById(R.id.webView); WebSettings web_sett=web_v.getSettings(); web_sett.setJavaScriptEnabled(true); web_v.setWebViewClient(new MyWebClient()); web_v.loadUrl("http://stream.us.gslb.liquidcompass.net/WPWXFMMP3"); return inflater.inflate(R.layout.fragment_listen_live, container, false); //return v; } private class MyWebClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // TODO Auto-generated method stub web_v.loadUrl(url); return true; } }
fragment_listen_live.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.peekatu.maintemplate.ListenLiveFragment">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView"
android:layout_gravity="center" />
</FrameLayout>
HTML
<html>
<head>
<meta name="viewport" content="width=device-width">
</head>
<body>
<video controls="" autoplay="" name="media">
<source src="http://stream.us.gslb.liquidcompass.net/WPWXFMMP3" type="audio/mpeg">
</video>
</body>
</html>
2.My 2nd question is how do I stop the webviews from reloading every time the fragment is paused. Thank you.