我的Android应用显示“不幸的是,该应用已停止”错误。它仅包含启动屏幕。在模拟器(Android Nougat)中运行时,它可以完美运行。仅在我的移动设备(API级别22和Android 5.1)中运行时才会出现此问题。下面是mainActivity
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Handler handler = new Handler();
handler.postDelayed(r,3000);
}
Runnable r = new Runnable() {
@Override
public void run() {
Intent intent = new Intent(MainActivity.this,HomeActivity.class);
startActivity(intent);
finish();
}
};
}
在初始屏幕中,我仅显示图像。下面是activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_img"
tools:context="com.app.wallpaperandquoteshub.activities.MainActivity">
</RelativeLayout>
请帮助我解决这个问题:)