android - Splash screen doesn't load -
part of project want use splash screen. fine code, unfortunately splash screen doesn't load @ starting. manifest file is
<activity android:label="@string/app_name" android:name="com.example.gameplay.splashscreen" android:configchanges="orientation|keyboardhidden" android:theme="@android:style/theme.wallpaper.notitlebar.fullscreen" android:screenorientation="landscape"> </activity> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> <activity android:name="com.example.gameplay.game" android:configchanges="orientation|keyboardhidden" android:theme="@android:style/theme.wallpaper.notitlebar.fullscreen" android:screenorientation="landscape" android:label="@string/app_name"></activity>
splashscreen.java
public class splashscreen extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.splash_screen); thread welcomethread = new thread() { int wait = 0; @override public void run() { try { super.run(); while (wait < 2000) { sleep(100); wait += 100;} } catch (exception e) { system.out.println("splashscreen()"+e.tostring()); } { system.out.println("final statment run()"); } } }; welcomethread.start(); new asynctask<void, void, void>(){ @override protected void doinbackground(void... params) { layoutinflater inflater = (layoutinflater) splashscreen.this.getsystemservice(context.layout_inflater_service); game.cachedview = inflater.inflate(r.layout.activity_game, null, false); return null; } @override protected void onpostexecute(void avoid) { finish(); intent intent = new intent(getbasecontext(), game.class); intent.addflags(intent.flag_activity_no_animation); startactivity(intent); } }.execute(); } }
please me fix problem.
you should close activity after intent-filter , second activity had no intent-filter ..
<activity android:label="@string/app_name" android:name="com.example.gameplay.splashscreen" android:configchanges="orientation|keyboardhidden" android:theme="@android:style/theme.wallpaper.notitlebar.fullscreen" android:screenorientation="landscape"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name="com.example.gameplay.game" android:configchanges="orientation|keyboardhidden" android:theme="@android:style/theme.wallpaper.notitlebar.fullscreen" android:screenorientation="landscape" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.game" /> <category android:name="android.intent.category.default" /> </intent-filter> </activity>
Comments
Post a Comment