Thursday 26 January 2017

Create Splash Screen with timer in android

 FULL VIDEO HERE:-

 FULL CODE Here:-

Step 1 . add entry of Flash.java in manifest file:-

                                   Manifest.xml

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.searchmymarket.searchmymarket">
<application
    android:allowBackup="true"
    android:icon="@mipmap/searchicon"
    android:label="@string/app_name"
    android:screenOrientation="portrait"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    
    <activity
        android:name=".Flash"
        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>

Step 2 . Create activity_flash.xml in layout folder :-

                                       activity_flash.xml

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
    android:layout_width="match_parent"
    android:layout_height="@dimen/Nlogo"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_centerVertical="true"
    android:background="@mipmap/logo"
    android:scaleType="center" />
</RelativeLayout>

STEP 1.Create Flash.java file :-

                                         Flash.java

import android.content.Intent;

        import android.os.Bundle;

        import android.support.v7.app.AppCompatActivity;

public class FlashScreen extends AppCompatActivity {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_flashscreen);

        Thread s = new Thread() {
            public void run() {
                try {
                    sleep(2500);
                    Intent i = new Intent(FlashScreen.this, NavigationScreen.class);
                    startActivity(i);
                    finish();
                } catch (Exception e) {

                }
            }

        };

        s.start();
    }
}

No comments:

Post a Comment