运行代码时出现以下错误。我不知道如何阻止内存泄漏并摆脱这个问题。
08-30 10:00:32.538: E/WindowManager(851): Activity simplicity.in.TenderPopUpTabsActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@43fce660 that was originally added here
08-30 10:00:32.538: E/WindowManager(851): android.view.WindowLeaked: Activity simplicity.in.TenderPopUpTabsActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@43fce660 that was originally added here
08-30 10:00:32.538: E/WindowManager(851): at android.view.ViewRoot.<init>(ViewRoot.java:247)
08-30 10:00:32.538: E/WindowManager(851): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
08-30 10:00:32.538: E/WindowManager(851): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
08-30 10:00:32.538: E/WindowManager(851): at android.view.Window$LocalWindowManager.addView(Window.java:424)
08-30 10:00:32.538: E/WindowManager(851): at android.app.Dialog.show(Dialog.java:241)
08-30 10:00:32.538: E/WindowManager(851): at android.app.ProgressDialog.show(ProgressDialog.java:107)
08-30 10:00:32.538: E/WindowManager(851): at android.app.ProgressDialog.show(ProgressDialog.java:90)
08-30 10:00:32.538: E/WindowManager(851): at simplicity.in.PaymentActivity.transByPaymentGateway(PaymentActivity.java:263)
08-30 10:00:32.538: E/WindowManager(851): at simplicity.in.PaymentActivity.onClick(PaymentActivity.java:131)
08-30 10:00:32.538: E/WindowManager(851): at android.view.View.performClick(View.java:2408)
08-30 10:00:32.538: E/WindowManager(851): at android.view.View$PerformClick.run(View.java:8816)
08-30 10:00:32.538: E/WindowManager(851): at android.os.Handler.handleCallback(Handler.java:587)
08-30 10:00:32.538: E/WindowManager(851): at android.os.Handler.dispatchMessage(Handler.java:92)
08-30 10:00:32.538: E/WindowManager(851): at android.os.Looper.loop(Looper.java:123)
08-30 10:00:32.538: E/WindowManager(851): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-30 10:00:32.538: E/WindowManager(851): at java.lang.reflect.Method.invokeNative(Native Method)
08-30 10:00:32.538: E/WindowManager(851): at java.lang.reflect.Method.invoke(Method.java:521)
08-30 10:00:32.538: E/WindowManager(851): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-30 10:00:32.538: E/WindowManager(851): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-30 10:00:32.538: E/WindowManager(851): at dalvik.system.NativeStart.main(Native Method)
我正在使用下面的代码来解决内存泄漏问题。当我执行此方法时,发生了问题
private void transByPaymentGateway(final double ccAmt) {
dialog = ProgressDialog.show(PaymentActivity.this, "", "Processing Transaction...", true);
new Thread(new Runnable() {
public void run() {
boolean successful = false;
final String totalAmt;
if(ccAmt <25){
totalAmt = Double.toString(amount);
AnyPayment anyPayment = new AnyPayment(PaymentActivity.this);
successful = anyPayment.payAmount(Name, Number,totalAmt);
}
}
if(successful){
runOnUiThread(new Runnable() {
public void run() {
showApprovalToast();
Variables.creditCardAmount = amount;
getReceiptfromPrinter();
saveTransactioDetails();
if(Variables.customerEmailId.equals("")){
System.out.println("Customer is Not associated");
}
else{
System.out.println("Testing email"+Variables.customerEmailId);
System.out.println("Testing"+Variables.customerId);
FacebookSharingUtils facebookSharingUtils = new FacebookSharingUtils(PaymentActivity.this);
facebookSharingUtils.execute();
}
}
});
finish();
}
else{
runOnUiThread(new Runnable() {
public void run() {
showCcSwipeMessage();
infoOnSwipeEditText.setText("");
dialog.dismiss();
}
});
}
}
}).start();
}
请指导我解决此问题的最佳方法