I am developing an application for the Galaxy S4. One of the requirements of the application is the presence of SplashScreen, which contains a 1920x1080 image. Its high quality .jpeg image and image size of approximately 2 megabytes .
The problem is that I get an OutOfMemoryError as soon as I launch the application. I'm pretty stunned that this is already happening with an image of just 2 megabytes? How can I fix this problem and display the image?
Resizing or resizing an image is not an option.
SplashScreen.java
public class Splashscreen extends Activity { private static final int SPLASH_DURATION = 2000; private boolean isBackPressed = false; @Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); setContentView(R.layout.splashscreen); Handler h = new Handler(); h.postDelayed(new Runnable() { @Override public void run() {
And splashscreen.xml
<ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ivSplashScreenImage" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="fitXY" android:src="@drawable/high_res_splashscreen_image"/>
ADDITIONAL INFORMATION:
Sometimes (when a lot of device memory is available), an application may go past the splash screen, but then the applicationโs memory consumption is just crazy . (about 100 megabytes) . Despite the fact that I close the activity of SplashScreen and exit (), it seems that there is a link to ImageView / Image stored in memory.
How to reduce the amount of memory in memory?
When I do not show the screen saver, my application consumes only about 35 MB of memory. With SplashScreen image - about 100 MB.
android image out-of-memory bitmap android-imageview
Philip jahoda
source share