ورود

View Full Version : اضافه کردن alert dialog به برنامه و مشاهده خطای java.lang.OutOfMemoryError:



CodeforLife
دوشنبه 02 اسفند 1395, 08:55 صبح
سلام دوستان من در برنامه یه دیالوگ ایجاد کردم که قبل از انجام عملیات از کاربر بپرسه که مطمئن بشه که کار رو انجام بده یا نه؟

ولی این خطا رو دارم



FATAL EXCEPTION: main
Process: com.qualcomm.qti.tetherservice, PID: 4268
java.lang.OutOfMemoryError: Could not allocate JNI Env
at java.lang.Thread.nativeCreate(Native Method)
at java.lang.Thread.start(Thread.java:1063)

این هم کدها



imgInsert.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder alert = new AlertDialog.Builder(G.context);
alert.
setCancelable(false)
.setMessage("آیا از درج اطلاعات در بانک اطمینان دارید؟")
.setPositiveButton("بله",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
// G.thread = new Thread(new Runnable() {
// @Override
// public void run() {
setCustomer();
setBike();
//insert
customerApi.insertDelivery();
bikeApi.insertDelivery();
//true isBike
bikeApi.setIsBike();
customerApi.setIsBike();
//send sms
admin.sendSms(G.phoneNumber, G.firstName + " " + G.lastName, G.pelakNumber, G.deliveryId);
// }
// });
// G.thread.start();

}
})
.setNegativeButton("خیر",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.cancel();
finish();
}
});
AlertDialog a = alert.create();
a.setTitle("");
a.show();
//
//my handler
//
handler = new Handler();
Runnable runnable = new Runnable() {
@Override
public void run() {
if (G.RETURN_RESULT) {
Toast.makeText(G.context, "تراکنش با موفقیت انجام گردید و پیامک حاوی کد معرف ارسال گردید", Toast.LENGTH_SHORT).show();
G.RETURN_RESULT = false;
}
if (!G.TOAST_RESULT) {
Toast.makeText(G.context, "خطا در سمت سرور ", Toast.LENGTH_SHORT).show();
G.TOAST_RESULT = true;
}
handler.postDelayed(this, 1000);
}
};
handler.postDelayed(runnable, 1000);
}
});



لطفا راهنماییم کنید