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 客户端还没有准备好..
我曾在一些类似的问题阅读,以便增加:在清单真”,在“机器人出口=”可以解决这个问题,但它不会在我的情况下。
它与你的代码无关。这是因为你的仿真器/设备还没有准备好。尝试在AS终端中执行'adb kill-server'和'adb start-server',然后再试一次 –
我只在我的设备上运行我的应用程序,我从不使用任何模拟器。我尝试输入你的命令,但它不会改变任何东西 – gamerounet