Webサービスからリストビューに画像を表示しています。アプリケーションを10回テストし、その後6回この例外が発生した場合は、誰か助けてください。AsyncTaskを使用してWebサービスを呼び出しています。
06-12 14:49:53.132: E/dalvikvm-heap(3071): Out of memory on a 1920016-byte allocation.
06-12 14:49:53.160: E/AndroidRuntime(3071): FATAL EXCEPTION: AsyncTask #3
06-12 14:49:53.160: E/AndroidRuntime(3071): java.lang.RuntimeException: An error occured while executing doInBackground()
06-12 14:49:53.160: E/AndroidRuntime(3071): at android.os.AsyncTask$3.done(AsyncTask.java:278)
06-12 14:49:53.160: E/AndroidRuntime(3071): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
06-12 14:49:53.160: E/AndroidRuntime(3071): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
06-12 14:49:53.160: E/AndroidRuntime(3071): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
06-12 14:49:53.160: E/AndroidRuntime(3071): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
06-12 14:49:53.160: E/AndroidRuntime(3071): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
06-12 14:49:53.160: E/AndroidRuntime(3071): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
06-12 14:49:53.160: E/AndroidRuntime(3071): at java.lang.Thread.run(Thread.java:856)
06-12 14:49:53.160: E/AndroidRuntime(3071): Caused by: java.lang.OutOfMemoryError
06-12 14:49:53.160: E/AndroidRuntime(3071): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
06-12 14:49:53.160: E/AndroidRuntime(3071): at an droid.graphics.BitmapFactory.decodeStream(BitmapFactory.java:493)
06-12 14:49:53.160: E/AndroidRuntime(3071): at com.rentfaster.utilities.ImageLoader.decodeFile(ImageLoader.java:142)
06-12 14:49:53.160: E/AndroidRuntime(3071): at com.rentfaster.utilities.ImageLoader.getBitmap(ImageLoader.java:78)
06-12 14:49:53.160: E/AndroidRuntime(3071): at com.rentfaster.handler.DetailPhotoHandler.imagefecher(DetailPhotoHandler.java:211)
06-12 14:49:53.160: E/AndroidRuntime(3071): at com.rentfaster.handler.DetailPhotoHandler.characters(DetailPhotoHandler.java:153)
06-12 14:49:53.160: E/AndroidRuntime(3071): at org.apache.harmony.xml.ExpatParser.text(ExpatParser.java:163)
06-12 14:49:53.160: E/AndroidRuntime(3071): at org.apache.harmony.xml.ExpatParser.appendBytes(Native Method)
06-12 14:49:53.160: E/AndroidRuntime(3071): at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:513)
06-12 14:49:53.160: E/AndroidRuntime(3071): at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:474)
06-12 14:49:53.160: E/AndroidRuntime(3071): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:321)
06-12 14:49:53.160: E/AndroidRuntime(3071): at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:279)
06-12 14:49:53.160: E/AndroidRuntime(3071): at com.rentfaster.home.PropertyDetail$Photostask.doInBackground(PropertyDetail.java:1174)
06-12 14:49:53.160: E/AndroidRuntime(3071): at com.rentfaster.home.PropertyDetail$Photostask.doInBackground(PropertyDetail.java:1)
06-12 14:49:53.160: E/AndroidRuntime(3071): at android.os.AsyncTask$2.call(AsyncTask.java:264)
06-12 14:49:53.160: E/AndroidRuntime(3071): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
06-12 14:49:53.160: E/AndroidRuntime(3071): ... 4 more
06-12 14:50:02.882: E/parse exception0(3258): dont know why
06-12 14:50:02.882: E/XML Error(3258): java.net.MalformedURLException: Protocol not found: &area=53.447557,-113.460058,53.447557,-113.460058&max=100
06-12 14:50:02.921: E/MapActivity(3258): Couldn't get connection factory client
私はまだメモリ不足の問題に直面しています、私はこのコードを使用しています私を助けてください
//decodes image and scales it to reduce memory consumption
private static Bitmap decodeFile(File f){
try {
//decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inSampleSize = 2;
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(new FileInputStream(f),null,o);
//Find the correct scale value. It should be the power of 2.
final int REQUIRED_SIZE=70;
int width_tmp=o.outWidth, height_tmp=o.outHeight;
int scale=1;
while(true){
if(width_tmp/2<REQUIRED_SIZE || height_tmp/2<REQUIRED_SIZE)
break;
width_tmp/=2;
height_tmp/=2;
scale*=2;
}
//decode with inSampleSize
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize=2;
return BitmapFactory.decodeStream(new FileInputStream(f), null, null);
} catch (FileNotFoundException e) {}
return null;
}