Код: Выделить всё
java.lang.RuntimeException: Could not copy bitmap to parcel blob.
at android.graphics.Bitmap.nativeWriteToParcel(Native Method)
at android.graphics.Bitmap.writeToParcel(Bitmap.java:2157)
at android.os.Parcel.writeParcelable(Parcel.java:2538)
at android.os.Parcel.writeValue(Parcel.java:2439)
at android.os.Parcel.writeValue(Parcel.java:2316)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:1265)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1802)
at android.os.Bundle.writeToParcel(Bundle.java:1362)
at android.os.Parcel.writeBundle(Parcel.java:1334)
at android.os.Parcel.writeValue(Parcel.java:2433)
at android.os.Parcel.writeValue(Parcel.java:2323)
at android.os.Parcel.writeSparseArray(Parcel.java:1422)
at android.os.Parcel.writeValue(Parcel.java:2463)
at android.os.Parcel.writeValue(Parcel.java:2316)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:1265)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1802)
at android.os.Bundle.writeToParcel(Bundle.java:1362)
at android.os.Parcel.writeBundle(Parcel.java:1334)
at android.os.Parcel.writeValue(Parcel.java:2433)
at android.os.Parcel.writeValue(Parcel.java:2323)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:1265)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1802)
at android.os.Bundle.writeToParcel(Bundle.java:1362)
at android.os.Parcel.writeBundle(Parcel.java:1334)
at android.os.Parcel.writeValue(Parcel.java:2433)
at android.os.Parcel.writeValue(Parcel.java:2323)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:1265)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1802)
at android.os.Bundle.writeToParcel(Bundle.java:1362)
at android.os.Parcel.writeBundle(Parcel.java:1334)
at android.os.Parcel.writeValue(Parcel.java:2433)
at android.os.Parcel.writeValue(Parcel.java:2323)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:1265)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1802)
at android.os.Bundle.writeToParcel(Bundle.java:1362)
at android.os.Parcel.writeTypedObject(Parcel.java:2157)
at android.app.IActivityClientController$Stub$Proxy.activityStopped(IActivityClientController.java:1257)
at android.app.ActivityClient.activityStopped(ActivityClient.java:99)
at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:143)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:210)
at android.os.Looper.loop(Looper.java:299)
at android.app.ActivityThread.main(ActivityThread.java:8247)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:559)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:954)
Ввод пользователя разделен на 3 этапа, каждый этап происходит в отдельном фрагменте.
- fragment1 принимает 3 аргумента. (ввод пользователя) Record(A,B,C)
- fragment2 принимает 2 аргумента Record(A,B,C,D) с использованием сеттеров, конечно, до сих пор журнал записей не аварийно завершается .tostring заполняется по назначению.
- приложение fragment3 аварийно завершает работу при нажатии любой галереи/кнопки
Fragment3
[*]Макс. объем памяти составляет 250 МБ, это нормально?
Приложение не дает сбоев на эмуляторе Android, но протестировано несколько современных устройств Android, и все они вылетели.
Код: Выделить всё
if (result.getResultCode() == Activity.RESULT_OK) {
Intent data = result.getData();
if (data != null && data.getExtras() != null) {
Bitmap imageBitmap = (Bitmap) data.getExtras().get("data");
if (imageBitmap != null) {
Uri capturedImageUri = getImageUri(requireContext(), imageBitmap);
handleGalleryOrCameraResult(capturedImageUri, requestCode);
} else {
// Handle when the imageBitmap is null
}
}
}
}
private void handleGalleryOrCameraResult(Uri selectedImageUri,int requestCode) {
// Use the appropriate list based on the current scenario
List imageList;
TextView imageCounter;
RecyclerView recyclerView;
// Determine the scenario based on your logic
// For example, you can use a flag to identify whether it's for container, lock, or item
switch (requestCode) {
case 7: // Container
imageList = DamageGoodImageUris;
imageCounter = DamageGoodImageCounter;
recyclerView = DamageGoodRecyclerView;
break;
case 8: // Lock
imageList = HeatImageUris;
imageCounter = HeatImageCounter;
recyclerView = HeatRecyclerView;
break;
default:
return;
}
// Add the selected image URI to the respective model's image list
if (selectedImageUri != null) {
imageList.add(selectedImageUri);
}
// Update the RecyclerView with the new image list
setupRecyclerView(recyclerView, imageList, imageCounter);
}
// Helper method to get Uri from Bitmap
private Uri getImageUri(Context context, Bitmap bitmap) {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = MediaStore.Images.Media.insertImage(context.getContentResolver(), bitmap, "Title", null);
return Uri.parse(path);
}
Подробнее здесь: https://stackoverflow.com/questions/777 ... tton-click