私は Android セキュリティ アプリに取り組んでおり、ギャラリーから画像をロックする必要があるため、ギャラリーからアプリケーションに画像を移動しようとしています。
私はこのコードを使用しています:
Cursor cursor = cursor1[0];
int i = 0;
while (cursor.moveToNext()) {
String id = cursor.getString(cursor.getColumnIndex(MediaStore.Images.ImageColumns._ID));
long idC = Long.parseLong(id);
Uri newUri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, idC);
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(cr,newUri);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100,stream );
Bitmap compBit = Bitmap.createScaledBitmap(bitmap, 100,100, true);
bitmap1[i] = compBit;
bitmap.recycle();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
しかし、この例外が発生します:
4192360 バイトの割り当てでメモリが不足しています。