2016-06-09 57 views
1

我想將閃屏活動添加到我的應用程序。添加splashscreenactivity時,「客戶端還沒有準備好」

我使用的Android Studio 2.2中,預覽3

我只是修改我的表現,在新的活動添加:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="me.youactive.hts.youactive"> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity 
     android:name=".MainActivity" 
     android:label="YouactiveSlidingMenu" 
     android:screenOrientation="portrait"> 
    </activity> 
    <activity 
     android:name=".SplashScreenActivity" 
     android:exported="true"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
</application> 

,這裏是我的SplashScreenActivity.java

package me.youactive.hts.youactive; 

import android.content.Intent; 
import android.content.SharedPreferences; 
import android.os.Handler; 
import android.preference.PreferenceManager; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 

public class SplashScreenActivity extends AppCompatActivity 
{ 

private final int SPLASH_DISPLAY_LENGTH = 3000; 

@Override 
protected void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.splashscreen); 
} 

@Override 
protected void onResume() 
{ 
    super.onResume(); 
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); 
    // Obtain the sharedPreference, default to true if not available 
    boolean isSplashEnabled = sp.getBoolean("isSplashEnabled", true); 

    if (isSplashEnabled) 
    { 
     new Handler().postDelayed(new Runnable() 
     { 
      @Override 
      public void run() 
      { 
       //Finish the splash activity so it can't be returned to. 
       SplashScreenActivity.this.finish(); 
       // Create an Intent that will start the main activity. 
       Intent mainIntent = new Intent(SplashScreenActivity.this, MainActivity.class); 
       SplashScreenActivity.this.startActivity(mainIntent); 
      } 
     }, 3000); 
    } 
    else 
    { 
     // if the splash is not enabled, then finish the activity immediately and go to main. 
     finish(); 
     Intent mainIntent = new Intent(SplashScreenActivity.this, MainActivity.class); 
     SplashScreenActivity.this.startActivity(mainIntent); 
    } 
} 
} 

如果我改變我的清單,並把周圍的MainActivity,應用程序通貨膨脹推出全成

在我運行Windows,我可以看到這條消息:

亞行外殼上午開始-n 「me.project.com.project/me.project.com.project.MainActivity」 -a android.intent.action.MAIN -c android.intent.category.LAUNCHER 客戶端還沒有準備好..

我曾在一些類似的問題閱讀,以便增加:在清單真」,在「機器人出口=」可以解決這個問題,但它不會在我的情況下。

+0

它與你的代碼無關。這是因爲你的仿真器/設備還沒有準備好。嘗試在AS終端中執行'adb kill-server'和'adb start-server',然後再試一次 –

+0

我只在我的設備上運行我的應用程序,我從不使用任何模擬器。我嘗試輸入你的命令,但它不會改變任何東西 – gamerounet

回答

0

您的無線網絡連接可能是導致此錯誤的原因。

在進行任何與代碼相關的更改之前,重新連接到您的wifi可能是個好主意。