android - activity main MAIN and LAUNCHER is not fired first -


i have launcher activity followed loginactivity. everytime start app loginactivity fired first rather launcheractivity. xml manifest.xml like

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.kryptapps.konel.dchat2" >  <application     android:allowbackup="true"     android:icon="@mipmap/ic_launcher"     android:label="@string/app_name"     android:theme="@style/customtheme" >     <activity         android:name=".launcheractivity"         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=".loginactivity"         android:label="@string/title_activity_login" >     </activity>     <activity         android:name=".grouplistactivity"         android:label="@string/title_activity_group_list" >     </activity> </application>  </manifest> 

java file :

public class launcheractivity extends activity {     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_launcher);         loadpersonaldatas();          thread time = new thread() {             public void run() {                 try {                     sleep(20000);                 } catch (interruptedexception e) {                     e.printstacktrace();                 }             }         };         time.start();     }     void loadpersonaldatas(){         new thread() {             public void run() {                 try {                     sleep(500);                 } catch (interruptedexception e) {                     e.printstacktrace();                 }             }         }.start();         intent intent = new intent(this, loginactivity.class);         startactivity(intent);     }     @override     protected void onpause() {         super.onpause();         finish();     } } 

the login activity usual log in page.

actually launcheractivity getting fired, 500 milliseconds.

whats happening wait 20000 milliseconds , execution of loadpersonaldatas() carried out simultaneously.

but after 500 milliseconds, activity changes , sleep(20000) interrupted.

for loginactivity launch after 20000 milliseconds, should start loginactivity after sleep(20000) in run() method.

public class launcheractivity extends activity {     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_launcher);           thread time = new thread() {             public void run() {                 try {                     sleep(20000);                     loadpersonaldatas();             //start activity here                 } catch (interruptedexception e) {                     e.printstacktrace();                 }             }         };         time.start();     }     void loadpersonaldatas(){         new thread() {             public void run() {                 try {                     sleep(500);                 } catch (interruptedexception e) {                     e.printstacktrace();                 }             }         }.start();         intent intent = new intent(this, loginactivity.class);         startactivity(intent);     }     @override     protected void onpause() {         super.onpause();         finish();     } } 

now, loginactivity start after 20500 milliseconds.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -