My android code doesn't show main activity, it only shows splash screen and than close. It is unable to show the main Screen. I am going to share my all files except MainActicity. Kindly tell me what m doing wrong
Here is splash.java:
//splash.java
package com.example.myapplication;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class splash extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Thread td=new Thread(){
public void run()
{
try
{
sleep(3000);
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally
{
Intent it=new Intent(splash.this,MainActivity.class);
startActivity(it);
}
}
};td.start();
}
}
Here is activity_splash.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/age"
android:layout_marginLeft="70sp"
android:layout_marginTop="200sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/splashText"
android:layout_marginTop="450sp"
android:layout_marginLeft="5sp"
android:textSize="18sp"
android:textColor="@color/colorPrimaryDark"
android:textStyle="bold"
/>
</RelativeLayout>
here is AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.birthdaycountdown">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
</activity>
<activity android:name=".splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Kindly ans this question am just a beginner in android.
First check logcat what kind of issue you are facing. share logcae issue also.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.