android - splash screen shown as blank screen -
i made splash layout, last time , other activity should loaded,alone works perfectly, when it's connected other activity, shows blank screen.
mainifest
file :
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="andy.propaganda" android:installlocation="auto" > <application android:allowbackup="true" android:icon="@drawable/my_launcher" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/apptheme.noactionbar" > <activity android:name=".shit" android:label="@string/app_name" > <intent-filter> <action android:name="com.coderefer.androidsplashscreenexample.mainactivity" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity> <activity android:name=".splash" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <!-- attention: auto-generated add google play services project app indexing. see https://g.co/appindexing/androidstudio more information. --> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> </application> </manifest>
splash
activity :
package andy.propaganda; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.animation.animation; import android.view.animation.animationutils; import android.widget.imageview; /** * created andrew on 2/4/2016. */ public class splash extends activity { //welcome animation imageview loading_img; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.splash); loading_img = (imageview)findviewbyid(r.id.loading_view); final animation animatable = animationutils.loadanimation(this, r.anim.welcome_screen_anim); loading_img.setanimation(animatable); // for(int = 0;i< 100000000;i++); intent intent = new intent(this, shit.class); intent.putextra("jhjh", 8); startactivity(intent); } }
main
activity :
package andy.propaganda; import android.app.activity; import android.os.bundle; /** * created andrew on 2/5/2016. */ public class shit extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } }
splash.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" android:background="@color/myblue" > <imageview android:layout_width="300dp" android:layout_height="300dp" android:src="@drawable/my_launcher" android:paddingtop="60dp" android:id="@+id/imageview" android:layout_alignparenttop="true" android:layout_centerhorizontal="true" /> <imageview android:layout_width="75dp" android:layout_height="75dp" android:src="@drawable/loading" android:layout_marginbottom="43dp" android:id="@+id/loading_view" android:layout_alignparentbottom="true" android:layout_centerhorizontal="true" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="loading files" android:id="@+id/welcome_message" android:focusable="false" android:textcolor="#010101" android:textsize="@dimen/abc_action_bar_progress_bar_size" android:layout_above="@+id/loading_view" android:layout_alignright="@+id/imageview" android:layout_alignend="@+id/imageview" android:layout_marginbottom="50dp" /> </relativelayout>
you should use timer on splash screen instead of for(int = 0;i< 100000000;i++);
wait time suppose 5 sec , load activity.
package andy.propaganda; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.animation.animation; import android.view.animation.animationutils; import android.widget.imageview; /** * created andrew on 2/4/2016. */ public class splash extends activity { //welcome animation imageview loading_img; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.splash); loading_img = (imageview)findviewbyid(r.id.loading_view); final animation animatable = animationutils.loadanimation(this, r.anim.welcome_screen_anim); loading_img.setanimation(animatable); new timer().schedule(new timertask() { @override public void run() { // task intent intent = new intent(this, shit.class); intent.putextra("jhjh", 8); startactivity(intent); } }, 5000); } }
Comments
Post a Comment