【问题标题】:Splash screen android phonegap timing启动画面 android phonegap 计时
【发布时间】:2013-08-31 11:32:52
【问题描述】:

我在this answer找到了这段代码:

super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html",5000);

它可以工作,但是像这样,结果是:

  • 闪屏5秒

  • 在应用准备就绪之前黑屏

  • 应用准备就绪时的 index.html

所以我想知道是否有机会运行这个

super.loadUrl("file:///android_asset/www/index.html");

作为一些就绪函数的回调,有什么办法吗?

-编辑-

将其更改为 10 秒不会显示黑屏,但我想在应用准备就绪的同一时刻显示 index.html(不早,也不晚 :D)

【问题讨论】:

  • 尝试使用 super.loadUrl(Config.getStartUrl(), 10000);
  • 我明白了,但这样我们就不能确定应用程序是否准备好了,或者它是否已经准备好一段时间......
  • 我的意思是你尝试将延迟时间从 5000 增加到 10000
  • 是的,我明白,但我想在应用程序准备好之前展示它,而不是 10 秒。正如我所说,它可能已经准备好了,但我可能还没有!
  • 你看过这个问题吗? stackoverflow.com/questions/5587888/… 如果您没有重定向,它可能会起作用...

标签: android eclipse callback splash-screen


【解决方案1】:
        // Show LOGO ,start to  MainActivity that watting for some seconds
        new Handler().postDelayed(new Runnable() {
            public void run() {
                /*
                 * Create an Intent that will start the Main WordPress
                 * Activity.
                 */
                //
                RedirectMainActivity();
            }
        }, 4000);

【讨论】:

  • 你对phone-gap一无所知
  • 什么?能给我详细的吗!
【解决方案2】:

Android 不提供任何原生 API 来处理 Splash Screen 但是你可以使用Handler 来显示假的闪屏。

  //load the splash screen
  super.loadUrl("file:///android_asset/www/someSplashScreen.html");
  new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
                    // splash screen successfully timeout
                    //start new activity or load html layout
                     super.loadUrl("file:///android_asset/www/index.html");

        }
    }, 4000);//timeout after 4 sec

【讨论】:

  • 只有一个问题,为什么会延迟 4 秒?问题是我根本不想有额外的延迟,我只想将启动画面用作“加载”图像:),如果我输入 0,那会实现吗?谢谢!
  • 我已经花费了 4000 毫秒,例如你可以取任何你想要的值。
  • 如果你不想做背景工作,那么 200-800 毫秒就足够了,如果是 0 毫秒,我认为不会显示任何启动画面。
  • 我只想用启动画面替换应用程序准备就绪之前显示的黑屏...
  • 我对此一无所知。您需要让您的应用程序具有响应性。
【解决方案3】:

你试过了吗?

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;



     public class Splash extends Activity {

            private final int SPLASH_DISPLAY_LENGHT = 1000;

            /** Called when the activity is first created. */
            @Override
            public void onCreate(Bundle icicle) {
                super.onCreate(icicle);
                setContentView(R.layout.splashscreen);

                /* New Handler to start the Menu-Activity 
                 * and close this Splash-Screen after some seconds.*/
                new Handler().postDelayed(new Runnable(){
                    @Override
                    public void run() {
                        /* Create an Intent that will start the Menu-Activity. */
                        Intent mainIntent = new Intent(Splash.this,Menu.class);
                        Splash.this.startActivity(mainIntent);
                        Splash.this.finish();
                    }
                }, SPLASH_DISPLAY_LENGHT);
            }
        }

【讨论】:

    【解决方案4】:

    在您指向上一个问题的链接中,还有一个指向Blog 的链接

    它声称,使用 1.8.0 版的 PhoneGap,您可以致电 navigator.splashscreen.hide();

    查看博客(通读所有内容,因为前两段有点误导)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-08
      • 1970-01-01
      • 2011-12-30
      • 1970-01-01
      • 1970-01-01
      • 2013-01-23
      • 2014-11-19
      相关资源
      最近更新 更多