我的.swf文件位于项目的assets文件夹中。这是在尝试在应用程序启动之前运行该.swf文件然后跳转到主要活动的代码:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.webkit.WebView;
import android.webkit.WebSettings.PluginState;
public class Splash_Screen extends Activity {
private static int SPLASH_TIME_OUT = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.startup);
String localUrl ="file:///android_asset/Kiss-o-meter.swf";
WebView wv=(WebView) findViewById(R.id.webview);
wv.getSettings().setPluginState(PluginState.ON);
wv.loadUrl(localUrl);
new Handler().postDelayed(new Runnable() {
/*
* Showing splash screen with a timer. This will be useful when you
* want to show case your app logo / company
*/
@Override
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
Intent yes_krao = new Intent(Splash_Screen.this, KissingMeter.class);
startActivity(yes_krao);
finish();
}
}, SPLASH_TIME_OUT);
}
}
当我点击我的Android设备上的应用程序图标时,会出现一个白色的屏幕显示定义的时间,应用程序会跳转到主要活动。无法弄清楚为什么.swf文件没有播放!
答案 0 :(得分:0)
根据这个Question,我曾经加载swf文件而不是加载html。
它的工作就像一个魅力。
添加到AndroidManifest.xml
android:hardwareAccelerated="true"
2
String url ="file:///android_asset/flash_file.swf";
oWebView = (WebView) findViewById(R.id.wvhPlayer);
oWebView.getSettings().setJavaScriptEnabled(true);
oWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
oWebView.loadUrl(url);