'How to run .swf Files on Android Device
I am new to android and just started working on flash objects, by which i mean .swf files. I have read a lot about using a web view to load the swf file stored in assets/SD location, but to no avail. i have got suggestions from How to Play local swf files in a webview , flash players, Adobe AIR features of setting an swf to make an apk, etc. But still i am not being able to run the .swf files satisfactorily, due to the following reasons :
Even thought i set everything as set in the above link, i am getting a blank screen, much to my dismay of flash player not currently being default ("Launch by Default" Option in Setting->Apps->Flash Player->Launch By Default), hence i can't run flash content.
I have applied Adobe AIR to actually get the apk of the swf file by following a lengthy process, but because of two reason : a) Very laborious process and b) per-Installation requirement of Adobe AIR makes the whole purpose a losing battle.
Lots of Jargon/Confusion in Flash and lots of news on how flash is not making updates to its products for mobile sector, and how android "has"/"trying to" move into html 5.
I would like you all to solve this remedy to get flash swf object running on Android with minimum plugin ad-dons to the browser. I would love to have the has less support files as possible for my work to be productive and educative as well.
I hereby attach a code snippet, which i was working to get the work done to get the swf file running :
Approach One :
import android.annotation.SuppressLint; import android.app.Activity; import android.os.Bundle; import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.LinearLayout; @SuppressLint("SetJavaScriptEnabled") public class SWFViewer extends Activity { WebView wvswf; LinearLayout linearLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_swfviewer); linearLayout = (LinearLayout) findViewById(R.id.linearLayout); wvswf = new WebView(SWFViewer.this); wvswf.getSettings().setJavaScriptEnabled(true); wvswf.getSettings().setPluginState(WebSettings.PluginState.ON); wvswf.getSettings().setAllowFileAccess(true); linearLayout.addView(wvswf, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); String Url = "file:///android_asset/main.swf"; wvswf.loadUrl(Url); } }
With the layout as :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.winit.nunna.swfviewer"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8"
android:maxSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.winit.nunna.swfviewer.SWFViewer"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
- Approach Two
Using Adobe AIR SDK, we create an apk using the main swf file, some xml files for configuration and app signing, we can release an apk.
Conclusion : The first is the easiest but no o/p
12-20 13:56:28.457: INFO/WindowManager(162): MediaPlayer.is not PlayingVideo
The later is cumbersome with lots of extra dependencies.
Please give me better options to get an affordable aka high/moderate performance Flash O/p.
Solution 1:[1]
There is no easy way to integrate swf files in native android (Java) code w/o using WebView.
If you state that your problem is solved by building an APK with Adobe AIR using the same swf then i think you did remedy your problem of getting the swf to android, but not actually do what you asked for in the question above.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Sumeet Basak |