【问题标题】:How to navigate from one screen to another screen automatically? [duplicate]如何自动从一个屏幕导航到另一个屏幕? [复制]
【发布时间】:2012-10-19 11:03:02
【问题描述】:

可能重复:
Android SplashScreen

我是 android 应用程序开发的新手。

我使用 android sdk 开发了一个 android 应用程序。我在三星标签中安装了.apk文件,它工作正常。

但我的要求是在我的应用程序主页启动之前,我必须在一个屏幕上显示我的公司徽标,并且每隔 5 秒在另一个屏幕上显示我的应用程序标题,之后我的应用程序主页必须自动显示。

请帮助我前进。

【问题讨论】:

  • 谷歌“启动画面”。在继续之前,您可能应该阅读一般的 Android(也许还有 java)。

标签: android


【解决方案1】:
       startTime = System.currentTimeMillis();


     TimerTask enableTask = new TimerTask() {
     public void run() {
             handler.post(new Runnable() {
                     public void run() {
                      currenttime = System.currentTimeMillis();
             if(currenttime-startTime > 30000) {

             Intent intent = new Intent(Activity.this,
                    nextActivity.class);

            startActivity(intent);
             }
             else {

              go.setVisibility(View.GONE);
             }
                     }
            });
     }};

  Timer t = new Timer();
  t.schedule(enableTask,1000, 30000);

【讨论】:

    【解决方案2】:

    在异步任务中使用 Thread.sleep() 作为:

    private class splashAsync extends AsyncTask<Void, Void, Void>
    {
            protected void onPreExecute(){
    
            }     
            protected Void doInBackground(Void... params) {
            try { 
                Thread.sleep(1000);
    
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return null;
            }
            protected void onPostExecute(Void v){
            startActivity(new Intent(Activity1.this,Activity2.class));
            finish();
            }
          }
    

    【讨论】:

      【解决方案3】:

      使用计时器。启动特定时间段的计时器。说 5 秒。计时器结束后,关闭显示公司徽标的第一个活动并开始第二个活动。

      【讨论】:

      • 将此作为评论添加或尝试向用户详细说明。
      猜你喜欢
      • 2010-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 2020-07-27
      • 1970-01-01
      • 2019-10-20
      • 1970-01-01
      相关资源
      最近更新 更多