package com.dswipu.dswipu;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.widget.Toast;
public class splash extends AppCompatActivity {
private static int SPLASH_TIME_OUT = 5000;
private UserSessionManager session;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
getActionBar().hide();
setContentView(R.layout.activity_splash);
Utility ut = new Utility(this);
if(!ut.checkInternet())
{
Toast.makeText(getApplicationContext(), "No internet connection",
Toast.LENGTH_LONG).show();
}
new Handler().postDelayed(new Runnable() {
/*
* Showing splash screen with a timer. This will be useful when you
* want to show case your app logo/company
*/
@Override
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
session = new UserSessionManager(getApplicationContext());
if (session.isUserLoggedIn()) {
Intent i = new Intent(getApplicationContext(), Home.class);
startActivity(i);
} else {
Intent i = new Intent(splash.this, Auth.class);
startActivity(i);
}
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}
}
十一月3日至16日:43:47.932 4037-4037/com.dswipu.dswipu E/AndroidRuntime:致命異常:主 工藝:com.dswipu.dswipu,PID:4037 java.lang中。 RuntimeException:無法啓動活動ComponentInfo {com.dswipu.dswipu/com.dswipu.dswipu.splash}:android.util.AndroidRuntimeException:requestFeature()必須在添加內容之前調用 at android.app.ActivityThread.performLaunchActivity( ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com。 android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 引起:android.util。 AndroidRuntimeException:必須在添加內容之前調用requestFeature() at com.android.internal.policy.PhoneWindow.requestFeature(PhoneWindow.java:317) at com.dswipu.dswipu.splash.onCreate(splash.java:22 ) 在android.app.Activity.performCreate(Activity.java:6237) 在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java :726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 03-16 11:43:47.934 1685-2328/system_process W/ActivityManager:強制結束活動com.dswipu.dswipu/.splash 03-16 11:43:48.237 1685-2328/system_process I/Wind owManager:截圖max retries 4令牌{e07b2da ActivityRecord {2395485 u0 com.dswipu.dswipu/.splash t17 f}} appWin = Window {8f28f3d u0 Starting com.dswipu.dswipu} drawState = 4 03-16 11:43: 48.268 2501-4094/com.google.android.gms D/DropBoxEntryAddedChimeraService:用戶未選擇使用&診斷。 03-16 11:43:48.296 1685-2572/system_process I/OpenGLRenderer:初始化的EGL 1.4版如何糾正這個錯誤「java.lang.RuntimeException:無法啓動活動ComponentInfo」?
任何解釋老兄?我們如何設想知道這個問題? –
在setContentview(R.layout.lay)之前調用requestFeature()方法 – Vadivel
我應該提供哪些代碼?以幫助我的問題得到解決更好..... –