android - How to start activity with splashscreen in hidden mode -
i have application starts displaying splashscreen 3 seconds calls activity kick in webview.
code splashscreen
package test.test; import test.test.r; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.motionevent; public class splashscreen extends activity { int timer = 0; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_splash_screen); thread splashthread = new thread() { @override public void run() { seek { while (timer < 3000) { sleep(100); timer += 100; } } grab (interruptedexception e) { // nil } { finish(); intent = new intent(); i.setclassname("test.test","test.test.mainmenu"); startactivity(i); } } }; splashthread.start(); } }
code xml splash
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:animatelayoutchanges="false" android:background="#57a11f" > <imageview android:id="@+id/imageview01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerinparent="true" android:contentdescription="@string/image" android:src="@drawable/splash" /> </relativelayout>
code webview
package test.test; import test.test.r; import android.app.activity; import android.net.connectivitymanager; import android.net.networkinfo; import android.os.bundle; import android.webkit.websettings; import android.webkit.webview; import android.webkit.webviewclient; public class mainmenu extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); overridependingtransition(android.r.anim.fade_in, android.r.anim.fade_out); setcontentview(r.layout.activity_mainmenu); webview webview = (webview) findviewbyid(r.id.webview); webview.getsettings().setappcachemaxsize( 10 * 1024 * 1024 ); webview.getsettings().setappcachepath( getapplicationcontext().getcachedir().getabsolutepath()+ "/cache" ); webview.getsettings().setallowfileaccess( true ); webview.getsettings().setappcacheenabled( true ); webview.setbackgroundcolor(0x00000000); webview.setwebviewclient(new webviewclient()); webview.getsettings().setjavascriptenabled( true ); webview.getsettings().setdomstorageenabled( true ); webview.getsettings().setcachemode( websettings.load_default ); if ( !isnetworkavailable() ) { webview.getsettings().setcachemode( websettings.load_cache_else_network ); } webview.loadurl( "http://www.google.com" ); } private boolean isnetworkavailable() { connectivitymanager connectivitymanager = (connectivitymanager) getsystemservice( connectivity_service ); networkinfo activenetworkinfo = connectivitymanager.getactivenetworkinfo(); homecoming activenetworkinfo != null; } }
code webview xml
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#57a11f" tools:context=".mainmenu" > <webview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:animatelayoutchanges="false" /> </relativelayout>
problem: when splashcreen calls webview activity, leaves me blank screen while, time download , render page.
what like: i'd know how can start splashscreen , webview @ same time having webview hidden has 3 seconds load , render page in background.
extra: not looking solutions using onpagefinished since want splashscreen remain on 3 seconds , btw using onpagefinished doesn't avoid render time needed set webpage on screen.
thank you!
use imageview , webview in same layout file , keeps webview in view.gone mode.
once spalsh screen finishes , enable webview view.viasible , imageview view.gone
pseudocode : webview=view.gone; imageview=view.visible; webview.loadurl="<some url>"; splasscreen timer 3 seconds; webview=view.visible; imageview=view.gone;
use relativelayout or framelayout
android webview screen splash-screen
No comments:
Post a Comment