1

I have a problem when I load interactive SWF file in android emulator. I use 2.3.1 AVD.

This is the code:

package com.androidpeople.view;

    import android.app.Activity;
    import android.os.Bundle;
    import android.webkit.WebView;

    public class WebViewExample extends Activity {

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            /*WebView webView = (WebView) findViewById(R.id.webview);
            webView.getSettings().setJavaScriptEnabled(true);
            webView.loadUrl("http://www.androidpeople.com");

            webView.setWebViewClient(new HelloWebViewClient());*/

            String html =
                "<object width=\"550\" height=\"400\"> <param name=\"movie\" value=\"file:///android_asset/FL.swf\"> <embed src=\"file:///android_asset/FL.swf\" width=\"550\" height=\"400\"> </embed> </object>";
                String mimeType = "text/html";
                String encoding = "utf-8";

            WebView wv=(WebView) findViewById(R.id.webview);
            wv.getSettings().setJavaScriptEnabled(true);
            wv.getSettings().setPluginsEnabled(true);
            wv.loadDataWithBaseURL("null", html, mimeType, encoding,  "");
            wv.setWebViewClient(new HelloWebViewClient());



        }
    }


package com.androidpeople.view;

import android.webkit.WebView;
import android.webkit.WebViewClient;

public class HelloWebViewClient extends WebViewClient {

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    view.loadUrl(url);
    return true;
}

} 

Manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.androidpeople.view"
  android:versionCode="1"
  android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".WebViewExample"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>
<uses-sdk android:minSdkVersion="5" />

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

</manifest> 

Now the problem is that when I run the project, it will give one box at center right side 3D dimension like:

this is the image

I have also tried to change different-different SWF file but can't get proper solution.

Can anyone help me? Thanks.

Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
Nikunj Patel
  • 21,853
  • 23
  • 89
  • 133

3 Answers3

3

That's just because you need to install flash Player. Download the apk from adobe website and install it on the emulator.

Waza_Be
  • 39,407
  • 49
  • 186
  • 260
  • Does that work when you browse the web? are flash animations displayed? – Waza_Be Jul 12 '11 at 04:46
  • ya. and also ,my flash developer generate one apk via Adobe-air and when they test in device it is working fine but when i am trying to do this way any interactive swf file i got problem to load in device. one more thing i want to tell you is that when i try to load non-interactive swf file it will work fine. but problem is raise here.... – Nikunj Patel Jul 12 '11 at 06:38
  • i think is there problem of action script version? becase i have use actiion script 3.0 – Nikunj Patel Jul 12 '11 at 06:40
  • is there any caution by suggest you to chose swf file(caution in meaning of size r else)? – Nikunj Patel Jul 12 '11 at 06:42
3

Replace

wv.loadDataWithBaseURL("null", html, mimeType, encoding,  ""); 

with

wv.loadData(html, mimeType, encoding,  "");
wv.getSettings().setJavaScriptEnabled(true);  
Sherif elKhatib
  • 45,786
  • 16
  • 89
  • 106
  • i have the same problem with emulator i have done as you suggested but all i got is just the blue symbol in the above image has gone but unable to see the animation and all my code was correct i have posted the question here please help me! http://stackoverflow.com/questions/9308712/how-to-run-the-swf-file-in-android-emulator – VENKI Feb 17 '12 at 15:06
0

Flash cannot run on the emulator!
At least, I did not find a way to do so. But, you can download an APK from this site and install it on your device. Then, using the following code I got flash to work.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    WebView webView = (WebView) findViewById(R.id.webview);
    webView.getSettings().setPluginState(WebSettings.PluginState.ON);
    webView.loadUrl("http://www.adobe.com/software/flash/about/");
}

In activity_main.xml:

<WebView  xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
Michel
  • 1,395
  • 13
  • 14