Reputation: 327
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. Also I tried to show a simple website and it shows also a empty window.
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. I thought that the problem is in this file and I tried to load a simple website, but also without result.
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
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!
Upvotes: 0
Views: 199
Reputation: 42640
SWF is a ShockWaveFlash file. Web browsers can not run/display a ShockWave Flash File without the help of the Flash Plugin.
The Flash Plugin for Android has been discontinued several years ago. Therefore you won't succeed in making it run in a WebView.
Hence you have to re-think your application design and how you can achieve whyt you want without that SWF file.
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).
Upvotes: 1