Where The Streets Have No Name

phonegap에서 flash구동시키기 본문

Developement/Mobile

phonegap에서 flash구동시키기

highheat 2011. 6. 23. 10:01


위와 같이 안드로이드 프로제트를 생성합니다.
activity클래스를 phonegap에서 제공되는 DroidGap으로 고친후 webview의 플러그인을 활성화하는 코드를 추가합니다

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebSettings.PluginState;

import com.phonegap.*;

public class FlashTestActivity extends DroidGap {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); 
        super.loadUrl("file:///android_asset/www/index.html");
                
        WebSettings settings = this.appView.getSettings();  
        settings.setPluginsEnabled(true);
        //settings.setPluginState(PluginState.ON);
      
    }
}

아래 layout xml에서 webview를 추가합니다.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
          <WebView android:id="@+id/appView"
            android:layout_height="fill_parent"
            android:layout_width="fill_parent"
            />	
</LinearLayout>


/assets/www/index.html을 작성해서 아래와 같이 flash파일을 추가한다.

<!DOCTYPE HTML>
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>Flash Test</title>
	<script type="text/javascript" charset="utf-8" src="phonegap.0.9.5.1.js"></script>
  </head>
  <body>   
    <h1>Flash Test</h1>  
    <img class="tx-entry-embed" src="http://cfs.tistory.com/static/admin/editor/spacer.gif" width="100" height="100"  type="application/x-shockwave-flash"/>
  </body>
</html>