私は、スプラッシュスクリーンを6秒間表示するAndroidアプリケーションを持っていますが、スプラッシュスクリーンはアプリケーションを開くときに表示されず、代わりに以前のスタートページだったスクリーンが表示されます。ここで スプラッシュスクリーンが表示されない
はsplashscreen.java
ファイルです。ここで
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.os.Handler;
public class splashscreen extends AppCompatActivity {
private static int SPLASH_TIME_OUT = 6000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splashscreen);
new Handler().postDelayed(new Runnable() {
// Using handler with postDelayed called runnable run method
@Override
public void run() {
Intent i = new Intent(splashscreen.this, LoginActivity.class);
startActivity(i);
// close this activity
//finish();
}
}, 6*1000);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_splashscreen, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
...
ここでは私のmanifest
ファイル -
あるsplashscreen.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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="16dp"
android:paddingTop="56dp"
android:paddingBottom="56dp"
android:background="@drawable/back1"
tools:context="com.example.lenovo.doccorduser.splashscreen">
<ImageView
android:id="@+id/imgLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/foetus"
android:layout_alignTop="@+id/textView4"
android:layout_centerHorizontal="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@mipmap/doccord"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="DocCord"
android:textStyle="bold"
android:id="@+id/textView4"
android:layout_below="@+id/imageView"
android:layout_centerHorizontal="true"
android:focusable="false"
android:textColor="@android:color/holo_orange_light" />
</RelativeLayout>
が助けてくださいです
あなたはインスタンスを保持せず、ondestroyイベントをオーバーライドしていないことを確認してください。あなたのondestroyコードを表示します。 –
コードが正常であるようです。プロジェクトのクリーニングと再構築を試してください。 –
'Logcat'に' Errors'がありますか?投稿してください。 –