Swiffy not showing in Android webview

111 Views Asked by At

I have an swf file I want to play on android, but since swf is not officially supported on android 4.0+, I'm using google swiffy to convert swf to html5. I have tried this code but it is not working, webview just showing white blank screen.

public class MainActivity extends AppCompatActivity {  
    @Override  
    public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview);  
        WebView wv;  
        wv = (WebView) findViewById(R.id.webView1);  
        wv.getSettings().setJavaScriptEnabled(true);
        wv.loadUrl("file:///android_asset/swiffy.html");
    }  
}

Swiffy code: https://www.dropbox.com/s/481mlqc8ym497q1/swiffy.html?dl=0

1

There are 1 best solutions below

2
VC.One On

Untested at the moment but... I'm wondering if there's a security issue with your HTML (on local storage) trying to access an online file? If swiffy.html was online it might work normally, but since it's on storage then make sure the JS file is on same place in storage too.

The source of swiffy.html loads a https://www.gstatic.com/swiffy/v7.4/runtime.js

Possible fix :
1) Save this JS file to the same place as your swiffy.html

2) Edit the source code of swiffy.html, change the line below...

<script type="text/javascript" src="https://www.gstatic.com/swiffy/v7.4/runtime.js"></script>

To become like this...

<script type="text/javascript" src="file:///android_asset/runtime.js"></script>

Save as swiffy_v2.html and test that in your webView code as :

wv.loadUrl("file:///android_asset/swiffy_v2.html");

Edit from comments :
Another fix is to just add the allowing of internet access in the app's manifest file. This solves the issue of loading the online JS file from a local HTML file.