I am new to both android and flash development. I am creating a metronome for my guitar app by using flash to implement the metronome portion. I already have a working project for the guitar and a separate flash file that I created for the metronome animation.
I have done a lot of research on this website and cant seem to find anything that is working, my code is below. Am I just making a rookie mistake or is there something bigger that I can try that will work better for me.
My goal is to have the activity access the Metronome.swf file and play it just as the .apk generated by flash does.
Here is my metronome.xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
And this is my MetronomeActivity.java file:
package itcs4155.group4.guitarTeacher;
import android.os.Bundle;
import android.webkit.WebView;
public class MetronomeActivity extends BaseActivity {
private WebView mWebView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.metronome);
mWebView = (WebView)findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
String html = "<object width=\"768\" height=\"1024\"> <param name=\"movie\" value=\"file:///android_asset/Metronome.swf\"> <embed src=\"file:///android_asset/Metronome.swf\" width=\"768\" height=\"1024\"> </embed> </object>";
String mimeType = "text/html";
String encoding = "utf-8";
mWebView.loadDataWithBaseURL("null", html, mimeType, encoding, "");
}
}
Thanks for any help in advance!
Some times it may happen that the swf file get loaded on the web view by is not displayed.
Try adding android:android:hardwareAccelerated=”true” in your manifest file.
It might help…