Question

I'm passing an HTML string to my Fragment. It loads it into a WebView but nothing happens, the fragment remains empty.

I'm pretty sure (thanks to logs) that my Fragment is receiving the HTML string.

That's the Fragment code:

private WebView mWebView;
String html;

@Override
public void onCreate(Bundle savedInstanceState) {
    Log.d(MainActivity.TAG, "VideogamesWebViewFragment --> onCreate()");
    super.onCreate(savedInstanceState);
}

public void onActivityCreated(Bundle savedInstanceState)
{
    Bundle bundle = this.getArguments();
    if(bundle != null)
    {
        html = bundle.getString("html");
    }

super.onActivityCreated(savedInstanceState);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    Log.d(MainActivity.TAG, "VideogamesWebViewFragment --> onCreateView()");
    View view = inflater.inflate(R.layout.default_web_view, container,
            false);
    mWebView = (WebView) view.findViewById(R.id.webview);   
    mWebView.getSettings().setLoadsImagesAutomatically(true);         
    //load html string   
    mWebView.loadData(html, "text/html", null);  

    return view;
}

@Override
public void onDestroy() {
    Log.d(MainActivity.TAG, "VideogamesWebViewFragment --> onDestroy()");
    super.onDestroy();
}

@Override
public void onDestroyView() {
    Log.d(MainActivity.TAG, "VideogamesWebViewFragment --> onDestroyView()");
    super.onDestroyView();
}

@Override
public void onResume() {
    super.onResume();
    Log.d(MainActivity.TAG, "VideogamesWebViewFragment --> onResume()");
}

@Override
public void onViewStateRestored(Bundle savedInstanceState) {
    super.onViewStateRestored(savedInstanceState);  
    Log.d(MainActivity.TAG,"VideogamesWebViewFragment --> onViewStateRestored()");
}  

I also get these errors:

03-07 07:09:41.626: D/Ludos(3053): VideogamesWebViewFragment --> onCreate()
03-07 07:09:41.626: D/Ludos(3053): VideogamesWebViewFragment --> onCreateView()
03-07 07:09:41.636: V/WebViewChromium(3053): Binding Chromium to the background looper Looper{b100af18}
03-07 07:09:41.636: I/chromium(3053): [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0
03-07 07:09:41.636: I/BrowserProcessMain(3053): Initializing chromium process, renderers=0
03-07 07:09:41.666: W/chromium(3053): [WARNING:proxy_service.cc(888)] PAC support disabled because there is no system implementation
03-07 07:09:41.756: D/Ludos(3053): VideogamesWebViewFragment --> onViewStateRestored()
03-07 07:09:41.756: D/Ludos(3053): VideogamesWebViewFragment --> onResume()
03-07 07:09:41.796: W/EGL_emulation(3053): eglSurfaceAttrib not implemented
03-07 07:09:41.806: W/AwContents(3053): nativeOnDraw failed; clearing to background color.
03-07 07:09:42.076: W/AwContents(3053): nativeOnDraw failed; clearing to background color.
03-07 07:09:42.476: E/eglCodecCommon(3053): glUtilsParamSize: unknow param 0x00000b44
03-07 07:09:42.486: E/eglCodecCommon(3053): glUtilsParamSize: unknow param 0x00000bd0
03-07 07:09:42.546: I/chromium(3053): [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
03-07 07:09:42.656: I/chromium(3053): [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
03-07 07:09:42.746: E/eglCodecCommon(3053): **** ERROR unknown type 0x0 (glSizeof,72)
03-07 07:09:42.776: E/eglCodecCommon(3053): glUtilsParamSize: unknow param 0x00000b44
03-07 07:09:42.786: E/eglCodecCommon(3053): glUtilsParamSize: unknow param 0x00000bd0
03-07 07:09:43.336: E/eglCodecCommon(3053): **** ERROR unknown type 0x0 (glSizeof,72)
03-07 07:09:43.376: E/eglCodecCommon(3053): glUtilsParamSize: unknow param 0x00000b44
03-07 07:09:43.386: E/eglCodecCommon(3053): glUtilsParamSize: unknow param 0x00000bd0
03-07 07:09:43.406: E/eglCodecCommon(3053): **** ERROR unknown type 0x0 (glSizeof,72)
03-07 07:09:43.416: E/eglCodecCommon(3053): glUtilsParamSize: unknow param 0x00000b44
03-07 07:09:43.426: E/eglCodecCommon(3053): glUtilsParamSize: unknow param 0x00000bd0
03-07 07:09:43.446: E/eglCodecCommon(3053): **** ERROR unknown type 0x0 (glSizeof,72)
03-07 07:09:43.456: E/eglCodecCommon(3053): glUtilsParamSize: unknow param 0x00000b44
03-07 07:09:43.476: E/eglCodecCommon(3053): glUtilsParamSize: unknow param 0x00000bd0
03-07 07:09:43.496: E/eglCodecCommon(3053): **** ERROR unknown type 0x0 (glSizeof,72)
03-07 07:09:43.506: E/eglCodecCommon(3053): glUtilsParamSize: unknow param 0x00000b44
03-07 07:09:43.516: E/eglCodecCommon(3053): glUtilsParamSize: unknow param 0x00000bd0
03-07 07:09:43.546: E/eglCodecCommon(3053): **** ERROR unknown type 0x0 (glSizeof,72)
03-07 07:09:43.546: E/eglCodecCommon(3053): glUtilsParamSize: unknow param 0x00000b44
03-07 07:09:43.566: E/eglCodecCommon(3053): glUtilsParamSize: unknow param 0x00000bd0  

Thanks!

Was it helpful?

Solution 2

onCreateView can be called before or after onActivityCreated depending on how you add your Fragment. Try loading the HTML in onResume or onStart

OTHER TIPS

Don't care about the errors you get from the logcat.

In my case, I loaded a site which contains a Image slider. The logcat produces the same error code when the image in slider is changes the images. I assumed that it might because of the webpage computes the size of the screen of my device. I just gussed because its from gl, Im not sure..

05-03 10:15:25.149: E/eglCodecCommon(5081): ERROR unknown type 0x1(glSizeof,73)

But it didn't trouble my app anymore.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top