感谢您的收看
我正在Android中创建我的第一个应用程序。
此应用有一个欢迎活动(第一个活动)和一个主活动(第二个活动)。
现在问题就出现了,当我打开我的应用程序并按回按钮进入主屏幕并重新打开应用程序并按回按钮进入主屏幕并重新打开应用程序时,只需快速执行此操作几次,然后应用程序崩溃甚至是移动设备重新启动。
以下是我欢迎的Activity XML,我试图删除android:src="@drawable/welcome"
,app刚刚正常工作,但我不知道真正的问题是什么,我真的需要一张欢迎图片。
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="example.givemepass.splashscreendemo.SplashActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
</android.support.design.widget.AppBarLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/app_name"
android:src="@drawable/welcome" />
</android.support.design.widget.CoordinatorLayout>
对不起,我的英语很差。
感谢您的收看。
ADD logcat:
12-04 10:26:34.424 8843-8843/? I/art: Late-enabling -Xcheck:jni
12-04 10:26:34.456 8843-8843/tw.com.cwgv.rs W/ResourceType: Found multiple library tables, ignoring...
12-04 10:26:34.545 8843-8858/tw.com.cwgv.rs I/art: Background sticky concurrent mark sweep GC freed 2640(199KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 26MB/26MB, paused 9.161ms total 15.174ms
12-04 10:26:34.602 8843-8890/tw.com.cwgv.rs D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
12-04 10:26:34.610 8843-8843/tw.com.cwgv.rs D/Atlas: Validating map...
12-04 10:26:34.654 8843-8890/tw.com.cwgv.rs I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.01.00.042.030_msm8974_LA.BF.1.1.1_RB1__release_AU ()
OpenGL ES Shader Compiler Version: E031.25.03.06
Build Date: 07/13/15 Mon
Local Branch: mybranch11906725
Remote Branch: quic/LA.BF.1.1.1_rb1.26
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.01.00.042.030 + 6151be1 + a1e0343 + 002d7d6 + 7d0e3f7 + NOTHING
12-04 10:26:34.656 8843-8890/tw.com.cwgv.rs I/OpenGLRenderer: Initialized EGL, version 1.4
12-04 10:26:34.669 8843-8890/tw.com.cwgv.rs D/OpenGLRenderer: Enabling debug mode 0
ADD WelcomeActivity.java:
public class WelcomeActivity extends AppCompatActivity {
final Handler startMainActivity_Handler = new Handler();
final Runnable startMainActivity_Runnable = new Runnable() {
@Override
public void run() {
startMainActivity();
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
try {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
}catch(Exception e){
Log.d("Some tag", Log.getStackTraceString(e.getCause().getCause()));
}
startMainActivity_Handler.postDelayed(startMainActivity_Runnable, 2000);
View currentView = this.findViewById(android.R.id.content);
currentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startMainActivity_Handler.removeCallbacks(startMainActivity_Runnable);
startMainActivity();
}
});
}
@Override
public void onBackPressed() {
Thread.currentThread().getStackTrace();
startMainActivity_Handler.removeCallbacks(startMainActivity_Runnable);
WelcomeActivity.this.finish();
System.exit(0);
}
protected void startMainActivity() {
startActivity(new Intent().setClass(WelcomeActivity.this, MainActivity.class));
WelcomeActivity.this.finish();
}
}