Android的启动画面画面、Android

2023-09-03 23:10:25 作者:妄定

这是我在我的包浏览器,以便让从顶部开始 和周围的工作我们的方式的地方,我认为这是找到问题。

this is what i have in my package explorer so lets start from the top and work our way around to the problem where i think it is located..

MainActivity.java -

MainActivity.java -

 package com.drg.idoser;

 import android.os.Bundle;
 import android.app.Activity;
 import android.view.Menu;

 public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

现在SplashActivity.java

now SplashActivity.java

package com.drg.idoser;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;

public class SplashActivity extends Activity {

 private static String TAG = SplashActivity.class.getName();
 private static long SLEEP_TIME = 5;    // Sleep for some time

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  this.requestWindowFeature(Window.FEATURE_NO_TITLE);    // Removes title bar
  this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,     WindowManager.LayoutParams.FLAG_FULLSCREEN);    // Removes notification bar

  setContentView(R.layout.splash);

  // Start timer and launch main activity
  IntentLauncher launcher = new IntentLauncher();
  launcher.start();
}

 private class IntentLauncher extends Thread {
  @Override
  /**
   * Sleep for some time and than start new activity.
   */
  public void run() {
     try {
        // Sleeping
        Thread.sleep(SLEEP_TIME*1000);
     } catch (Exception e) {
        Log.e(TAG, e.getMessage());
     }

     // Start main activity
     Intent intent = new Intent(SplashActivity.this, MainActivity.class);
     SplashActivity.this.startActivity(intent);
     SplashActivity.this.finish();
  }
}
}

activity_main.xml

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

</RelativeLayout>

splash.xml

splash.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@drawable/splash_bg"
android:layout_height="match_parent"
android:orientation="vertical" >


</LinearLayout>

AndroidManafest.xml

AndroidManafest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drg.idoser"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.drg.idoser.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

现在我想我的问题是 AndroidManafest.xml 我不认为我有splach屏幕树立正确的在 AndroidManafest.xml 当我启动我的应用我手机它跳转到 activity_main.xml 而非 splash.xml 即时通讯新的Andr​​oid应用程序,所以我似乎无法找到我的问题,但我需要我的闪屏,显示5秒如果任何人有TeamViwer并想帮我生病后我的会话信息,如果它会更快。

now i think my problem is in AndroidManafest.xml i dont think i have the splach screen set up right in the AndroidManafest.xml when i launch my application from my phone it jumps to activity_main.xml and not splash.xml im new to android applications so i cant seem to find my problem but i need my splash screen to show for 5 seconds if anyone has TeamViwer and would like to help me ill post my session info if it will be faster.

推荐答案

更​​改&lt;应用&GT; 标签下面的内容。你没有SplashActivity声明,并且有你MainActivity设置的发射活动。

Change your <application> tag to the following. You didn't have SplashActivity declared, and had your MainActivity setup as the launcher Activity.

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.drg.idoser.SplashActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.drg.idoser.MainActivity"
        android:label="@string/app_name" />
</application>