[英]Showing a .swf file in a WebView
can somebody help me please to show a .swf file into a WebView, I tried to do, but it shows a white windows instead of WebView. 有人可以帮我将.swf文件显示到WebView中吗,我尝试这样做,但是它显示的是白色窗口而不是WebView。 Also I tried to show a simple website and it shows also a empty window.
我也试图显示一个简单的网站,它也显示一个空窗口。
Fragment.java Fragment.java
package com.app.clupascu.oavm;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
public class FirstFragment extends Fragment {
@SuppressLint("SetJavaScriptEnabled")
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_first, container, false);
String url ="file:///android_asset/map.swf";
WebView mWebView=(WebView) v.findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
mWebView.loadUrl(url);
return inflater.inflate(R.layout.fragment_first, container, false);
}
}
Here I tried to load the .swf file into WebView. 在这里,我尝试将.swf文件加载到WebView中。 I thought that the problem is in this file and I tried to load a simple website, but also without result.
我以为问题出在此文件中,因此我尝试加载一个简单的网站,但也没有结果。
Fragment.xml fragment.xml之
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
MainPage.java MainPage.java
package com.app.clupascu.oavm;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
public class MainPage extends AppCompatActivity {
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.navigation_home:
setTitle("Map");
FirstFragment fragment = new FirstFragment();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fram, fragment);
fragmentTransaction.commit();
return true;
case R.id.navigation_dashboard:
setTitle("History");
SecondFragment fragment2 = new SecondFragment();
FragmentTransaction fragmentTransaction2 = getSupportFragmentManager().beginTransaction();
fragmentTransaction2.replace(R.id.fram, fragment2);
fragmentTransaction2.commit();
return true;
case R.id.navigation_notifications:
setTitle("Schedule");
ThirdFragment fragment3 = new ThirdFragment();
FragmentTransaction fragmentTransaction3 = getSupportFragmentManager().beginTransaction();
fragmentTransaction3.replace(R.id.fram, fragment3);
fragmentTransaction3.commit();
return true;
}
return false;
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_page);
BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
setTitle("Map");
FirstFragment fragment = new FirstFragment();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fram, fragment);
fragmentTransaction.commit();
}
}
Thank you! 谢谢!
SWF is a ShockWaveFlash file. SWF是ShockWaveFlash文件。 Web browsers can not run/display a ShockWave Flash File without the help of the Flash Plugin.
如果没有Flash插件的帮助,Web浏览器将无法运行/显示ShockWave Flash文件。
The Flash Plugin for Android has been discontinued several years ago. Android的Flash插件几年前已经停产。 Therefore you won't succeed in making it run in a WebView.
因此,您将无法使其成功在WebView中运行。
Hence you have to re-think your application design and how you can achieve whyt you want without that SWF file. 因此,您必须重新考虑您的应用程序设计,以及如何在没有该SWF文件的情况下实现所需的目标。
Anyway it is not a good idea to start a new app using a technology the will reach its end of life in 2 years (end of 2020) . 无论如何,使用一项将在两年内(2020年底)到期的技术启动新应用程序不是一个好主意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.