我有一个欢迎布局,这是我启动应用时的第一个布局。我可以在其他设备和Android Studio的模拟器中成功运行项目。
但是当我尝试使用三星Galaxy系列在Genymotion模拟器上运行时,它会显示错误
FATAL EXCEPTION:main进程:com.example.huaweb_system.taiwanuniversityhome,PID:2325 java.lang.OutOfMemoryError:无法分配157286412字节分配,其中包含6136736个空闲字节和87MB直到OOM
并标记此代码
at com.example.huaweb_system.taiwanuniversityhome.StartSplash.onCreate(StartSplash.java:49)
这是我欢迎的布局类:
public class StartSplash extends AppCompatActivity {
private ImageView imageStartSplash;
private static final int GOTO_MAIN_ACTIVITY = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_start_splash);//show error on this line
handler.sendEmptyMessageDelayed(GOTO_MAIN_ACTIVITY, 4000);
//my image is 1280*1920.png
imageStartSplash = (ImageView) findViewById(R.id.imageStartSplash);
//fade out image
AlphaAnimation alpha = new AlphaAnimation(1.0F, 0.0F);
alpha.setDuration(4000);
alpha.setFillAfter(true);
imageStartSplash.setAnimation(alpha);
}
//delay setting
private Handler handler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case GOTO_MAIN_ACTIVITY:
Intent intent = new Intent(StartSplash.this, MainActivity.class);
startActivity(intent);
finish();
break;
default:
break;
}
}
};
}
我真的不知道为什么?我尝试删除它们,如:
//imageStartSplash = (ImageView) findViewById(R.id.imageStartSplash);
//fade out image
//AlphaAnimation alpha = new AlphaAnimation(1.0F, 0.0F);
//alpha.setDuration(4000);
//alpha.setFillAfter(true);
//imageStartSplash.setAnimation(alpha);
它仍然显示错误......为什么会发生这种情况?
这是我的布局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:id="@+id/activity_start_splash"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.user.taiwandigestionsociety_v11.StartSplash">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
//i find that if i change the image smaller is would be fine.
app:srcCompat="@drawable/splash_screen_portrait_xxxhdpi_1280x1920"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:id="@+id/imageStartSplash" />
</RelativeLayout>