Bukan Materi Pelajaran yang Sulit, tapi Memulai Untuk Belajar itu yang Sulit.

Create Splash Screen use ActionBarActivity Andorid

3:34 PM Posted by Unknown No comments


بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم


Follow  this code Splash Screen Android

package com.rki.demokrado;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import com.rki.demokrado.navigationdrawers.NavigationDrawerWithAccountsAndFullHeightActivity;
import com.rki.demokrado.storege.PreferencedConnector;

public class Splash extends ActionBarActivity{

    protected boolean _active = true;
    protected int _splashTime = 4000;

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

        Thread splashTread = new Thread() {
            @Override
            public void run() {
                try {
                    int waited = 0;
                    while(_active && (waited < _splashTime)) {
                        sleep(30);
                        if(_active) {
                            waited += 50;
                        }
                    }
                } catch(InterruptedException e) {
                    // do nothing
                } finally {
                    if(PreferencedConnector.readString(getApplicationContext(),PreferencedConnector.ID_USERS, null)== null
                            || PreferencedConnector.readString(getApplicationContext(),PreferencedConnector.ID_USERS, null)== ""){

                        Intent newIntent=new Intent(Splash.this, Login.class);
                        startActivityForResult(newIntent, 0);
                        finish();

                    }else{
                        Intent newIntent=new Intent(Splash.this, NavigationDrawerWithAccountsAndFullHeightActivity.class);
                        startActivityForResult(newIntent, 0);
                        finish();
                    }
//                    Intent newIntent=new Intent(Splash.this, Login.class);
//                    startActivityForResult(newIntent, 0);
//                    finish();
                }
            }
        };
        splashTread.start();
    }
}


Layout Code for Interface


    

        

            

        

        

    

0 komentar:

Post a Comment