2013-09-25 6 views
1

안드로이드 사용자가 응용 프로그램 아이콘을 클릭하고 응용 프로그램이 시작될 때 .swf 파일을 재생하고 그 후에 응용 프로그램의 활동을 시작하려고합니다. 여기에 내가 생각한 것과 지금까지 내가 한 일이 있습니다. 여기 응용 프로그램 시작시 .swf 재생

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.os.Handler; 
import android.webkit.WebView; 
import android.webkit.WebSettings.PluginState; 

public class Splash_Screen extends Activity { 

    private static int SPLASH_TIME_OUT = 3000; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     // TODO Auto-generated method stub 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.startup); 

     new Handler().postDelayed(new Runnable() { 

      /* 
      * Showing splash screen with a timer. This will be useful when you 
      * want to show case your app logo/company 
      */ 

      @Override 
      public void run() { 
       // This method will be executed once the timer is over 
       // Start your app main activity 
       String localUrl ="file:///android_asset/Kiss-o-meter.swf"; 

       WebView wv=(WebView) findViewById(R.id.webview); 
       wv.getSettings().setPluginState(PluginState.ON); 
       wv.loadUrl(localUrl);  

       Intent yes_krao = new Intent(Splash_Screen.this, KissingMeter.class); 
       startActivity(yes_krao); 
       finish(); 
      } 
     }, SPLASH_TIME_OUT); 


    } 
} 

내 xml 파일이다 : 그것은 잘못 아무것도

<?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/webview" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent"/> 

</LinearLayout> 

있습니까? 코드가 작동하지 않는 것 같습니다! 둘째 setPluginsEnabled (true);도 eclipse에서 선택하지 않았습니다!

답변

1

startActivity(yes_krao)을 불러 오면 응용 프로그램에서 .swf가 재생되기 전에 응용 프로그램이 전환되도록 WebView을로드 한 직후에 호출됩니다. 한 가지 해결책은 Handler을 구현하고 .swf 파일 기간 후에 활동을 전환하는 것입니다.

예컨대 :

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.os.Handler; 
import android.webkit.WebView; 
import android.webkit.WebSettings.PluginState; 

public class Splash_Screen extends Activity { 

    private static int SPLASH_TIME_OUT = 3000; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     // TODO Auto-generated method stub 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.startup); 

     String localUrl ="file:///android_asset/Kiss-o-meter.swf"; 

     WebView wv=(WebView) findViewById(R.id.webview); 
     wv.getSettings().setPluginState(PluginState.ON); 
     wv.loadUrl(localUrl); 

     new Handler().postDelayed(new Runnable() { 

      /* 
      * Showing splash screen with a timer. This will be useful when you 
      * want to show case your app logo/company 
      */ 

      @Override 
      public void run() { 
       // This method will be executed once the timer is over 
       // Start your app main activity  
       Intent yes_krao = new Intent(Splash_Screen.this, KissingMeter.class); 
       startActivity(yes_krao); 
       finish(); 
      } 
     }, SPLASH_TIME_OUT); 
    } 
} 

참고 setPluginsEnabled()는 setPluginState을 (사용해야하므로는 사용되지 않습니다) :

WebSettings webSettings = yourWebView.getSettings(); 
webSettings.setPluginState(PluginState.ON); 
+0

내 편집 코드를 참조하십시오. 당신이 말하는 방식입니까? – Baba

+0

답변을 수락 할 수 있도록 체크하십시오 :) – Baba

+0

WebView 코드를 Handler 위에 올려 놓으십시오 (편집 된 답변 참조). 그러면 코드가 먼저 호출되고 SPLASH_TIME_OUT 후에 Intent가 호출되고 Activity가 변경됩니다. – ashatte

관련 문제