2016-11-23 44 views
-3

錯誤:無法分配與212762個免費字節499698字節分配和207KB,直到OOM內存分配錯誤的Android

public static Bitmap StringToBitMap(String input) { 
    byte[] decodedByte = Base64.decode(input, 0); 
    return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length); 
} 
+1

你的具體問題是什麼?錯誤消息似乎很清楚:設備根本沒有足夠的內存。所以你應該儘量減少應用程序的內存佔用量 – irundaia

回答

0
public static Bitmap StringToBitMap(String image) { 
     try { 
      byte[] bytarray = Base64.decode(image, Base64.DEFAULT); 
      return BitmapFactory.decodeByteArray(bytarray, 0, bytarray.length); 
     } catch (Exception e) { 
      e.getMessage(); 
      return null; 
     } catch (OutOfMemoryError e) { 
      Log.e("EWN", "Out of memory error catched"); 
      return null; 
     } 
    } 

使用這個,而不是希望你的幫助。

+0

不工作相同的錯誤.... –

0

嘗試在清單應用程序標記中添加android:largeHeap="true"