simply because @ time of splash screen, quick check , have play activity (webview or error activity). after splash screen activity white.
my class splash:
private static int tempo_splash = 1000; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.splash); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); // para o layout preencher toda tela cel (remover barra de tit.) new timer().schedule(new timertask() { @override public void run() { intent intent = new intent(); intent.setclass(splash.this, myconnectivitychecker.class); startactivity(intent); finish();//this should after starting intent } }, 2000); } }
now, manifest:
<uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.access_network_state"/> <uses-permission android:name="android.permission.access_wifi_state" /> <application android:allowbackup="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/apptheme" > <!-- activity mainactivity--> <activity android:name=".mainactivity" android:alwaysretaintaskstate="true" android:launchmode="singletop" android:configchanges="orientation|keyboardhidden" android:label="@string/app_name"> </activity> <!-- activity splash--> <activity android:name=".splash" android:launchmode="singletop"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <!-- activity myconnectivitychecker--> <activity android:name=".myconnectivitychecker" android:launchmode="singletop" android:alwaysretaintaskstate="true"> </activity> </application> </manifest>
follow check:
public class myconnectivitychecker extends activity { public void verificainternet() { connectivitymanager cm = (connectivitymanager) getsystemservice(context.connectivity_service); if (cm.getactivenetworkinfo()!= null && cm.getactivenetworkinfo().isavailable() && cm.getactivenetworkinfo().isconnected()) { intent = new intent(this, mainactivity.class); } else { intent = new intent(this, checkinternet.class); startactivity(i); } } }
and splash xml
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/backgrounds"> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imageview" android:background="@drawable/icon" android:layout_centervertical="true" android:layout_centerhorizontal="true" /> </relativelayout>
you should override oncreate method , call setcontentview splash activity