Where The Streets Have No Name

Appspresso 에서 Flash구동시키기 본문

Developement/Mobile

Appspresso 에서 Flash구동시키기

highheat 2012. 4. 23. 10:48
index.html에 추가할 부분
<!DOCTYPE html> 
<html> 
	<head> 
    	<script type="text/javascript" src="/appspresso/appspresso.js"></script> 
        <meta http-equiv="pragma" content="no-cache"/> 
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
        <script> 
        	//activate ax.log(), comment out when you release app 
            ax.runMode = ax.MODE_DEBUG; 
            ax.log("Hello World"); 
         </script>
     </head> 
     <body> 
     	<h1>Hello World</h1> 
        <h3>net.neocorea.flash</h3>
        <embed src="game1.swf" width="100%" height="100%" type="application/x-shockwave-flash"></embed>
      </body>
  </html>
플러그인 위치한 MyPlugin소스에서 추가할 부분
import android.webkit.WebSettings;

import com.appspresso.api.AxError;
import com.appspresso.api.AxPlugin;
import com.appspresso.api.AxPluginContext;
import com.appspresso.api.AxRuntimeContext;

public class MyPlugin implements AxPlugin {

	private AxRuntimeContext runtimeContext;

	@Override
	public void activate(AxRuntimeContext runtimeContext) {
		this.runtimeContext = runtimeContext;

		WebSettings settings = this.runtimeContext.getWebView().getSettings();
        settings.setPluginsEnabled(true);
	}

	@Override
	public void deactivate(AxRuntimeContext runtimeContext) {
		this.runtimeContext = null;
	}

	@Override
	public void execute(AxPluginContext context) {
		String method = context.getMethod();

		if ("echo".equals(method)) {
			String message = context.getParamAsString(0, null);
			context.sendResult(message);
		}
		else {
			context.sendError(AxError.NOT_AVAILABLE_ERR);
		}
	}

}