This error is happening in my application:
java.lang.OutOfMemoryError: Failed to allocate
My Image Code:
URL url1 = null;
try {
url1 = new URL("http://www.cm-mgrande.pt" + cabecalho);
} catch (MalformedURLException e) {
e.printStackTrace();
}
try {
InputStream input = url1.openConnection().getInputStream();
Bitmap bmp = BitmapFactory.decodeStream(input);
input.close();
BufferedReader in = new BufferedReader(
new InputStreamReader(url1.openStream()));
in.close();
imgcabecalho.setImageBitmap(bmp);
imgcabecalho.setScaleType(ImageView.ScaleType.FIT_XY);
} catch (IOException e) {
e.printStackTrace();
}
My Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:largeHeap="true"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Index"
android:configChanges="orientation|screenSize"
android:largeHeap="true"
android:label="@string/app_name" >
</activity>
</application>