Closed kedia1307 closed 4 years ago
If you set customBrowserConfig.setDisableBackButtonDialog(true) it means you don't want to show the back button dialog, inorder to show alert dialog on backpress kindly set it to false and then customize the back button dialog on onBackButton(AlertDialog.Builder alertDialogBuilder) callback
Thanks for the information, but I already tried this, After putting customBrowserConfig.setDisableBackButtonDialog(true), I tried adding my custom dialog on onBackButton(AlertDialog.Builder alertDialogBuilder) callback, but my dialog appears for fractions of seconds, and the CBActivity finishes simultaneously, which of course makes dialog appears for fractions of seconds, as the current activity(CBActivity) is finished I can't keep control of dialog. I debugged in your code, only to find out that if I set this customBrowserConfig.setDisableBackButtonDialog(true), you are finishing the activity. All you have to do is, comment that finish line of code and update your library, that way only it will work. I wasted my whole day, but got no outcome. I really like your library but help me on this please.
Have you tried by setting customBrowserConfig.setDisableBackButtonDialog(false)?
No, customBrowserConfig.setDisableBackButtonDialog(true).
This is the function being called on customBrowserConfig.setDisableBackButtonDialog(true)., it is there in CBActivity internal class of your library. Check in the following function, if its set true activity is being finished. that's what needs to be commented.
public void onBackPressed() { if (this.c != null && this.c.getDisableBackButtonDialog() != 1) { this.g.a("user_input", "payu_back_button".toLowerCase()); this.g.showBackButtonDialog(); } else { this.g.a("user_input", "m_back_button"); if (com.payu.custombrowser.bean.b.SINGLETON.getPayuCustomBrowserCallback() != null) { com.payu.custombrowser.bean.b.SINGLETON.getPayuCustomBrowserCallback().onBackButton((Builder)null); }
this.finish();
}
}
I hope its clear now??
This is the function being called on customBrowserConfig.setDisableBackButtonDialog(true)., it is there in CBActivity internal class of your library. Check in the following function, if its set true activity is being finished. that's what needs to be commented.
public void onBackPressed() { if (this.c != null && this.c.getDisableBackButtonDialog() != 1) { this.g.a("user_input", "payu_back_button".toLowerCase()); this.g.showBackButtonDialog(); } else { this.g.a("user_input", "m_back_button"); if (com.payu.custombrowser.bean.b.SINGLETON.getPayuCustomBrowserCallback() != null) { com.payu.custombrowser.bean.b.SINGLETON.getPayuCustomBrowserCallback().onBackButton((Builder)null); }
this.finish(); } }
I hope its clear now??
It is there since if you pass true to the method setDisableBackButtonDialog then it means no alert dialog would be shown on backpress hence no callback to customize the same.Hence if you need to customize the dialog on backpress then pass false to method setDisableBackButtonDialog,in return you will get the callback to override the dialog.
As per your documentation this is mentioned in the activity, which is misleading. It is working now!. thanks for your response. /**
As per your documentation this is mentioned in the activity, which is misleading. It is working now!. thanks for your response. /**
- This callback method will be invoked when setDisableBackButtonDialog is set to true.
- @param alertDialogBuilder a reference of AlertDialog.Builder to customize the dialog */
Which documentation you are referring to?
This is written in the Payment activity as a comment on this backPress fallback.
@himgupta229 One more issue I am facing right now is, when I try to click on the buttons I have added in my custom view and call onBackApprove()/onBackDismiss() function, nothing appears to happen. Please help.
@himgupta229 One more issue I am facing right now is, when I try to click on the buttons I have added in my custom view and call onBackApprove()/onBackDismiss() function, nothing appears to happen. Please help.
Can you paste your code snippet here to debug further?
Yes, here it is,
if (alertDialogBuilder != null) {
alertDialogBuilder
.setTitle("Cancel Transaction")
.setMessage("Do you want to cancel the ongoing payment?")
.setPositiveButton("Cancel payment", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
onBackApprove();
}
})
.setNegativeButton("Continue payment", new DialogInterface.OnClickListener() {
// do something when the button is clicked
public void onClick(DialogInterface dialog, int arg1) {
onBackDismiss();
}
});
}
this code is being called inside the callback, on negative button/positive button call it always cancels the dialog. I also tried adding custom view( as I need to change dialog background color), but listener does not work there also. Not sure what I am missing out here!
@himgupta229 Can u please solve this
@himgupta229 Can u please solve this
Can you post your callback code here? Have you overridden the method onBackDismiss()/onBackApprove()?
@himgupta229 Yes I have! Which Call back code do u want me to post here? I have posted above the call back code of onBackButton
@himgupta229 Yes I have! Which Call back code do u want me to post here? I have posted above the call back code of onBackButton
Paste the code of PayuCustomBrowserCallback.
Closing it since no input received for a week. If the issue still persists, kindly reopen it and provide the PayuCustomBrowserCallback code.
I am trying very hard to add my app's custom dialog if a user presses the back button from CBActivity. As per your document onBackButton(AlertDialog.Builder alertDialogBuilder) - This callback provides alert dialog access, so customisation can be done to alert dialog. But In your CBActivityI can find that you are finishing activity if customBrowserConfig.setDisableBackButtonDialog(true) is set true. whic ofcourse finishes the activity and I am not able to add my custom dialog. Please help.
It should work fine if you remove finish from your CBActivity. //following code is from CBActivity(unEditable) @override public void onBackPressed() { if (customBrowserConfig != null && customBrowserConfig.getDisableBackButtonDialog() != 1) { payUCustomBrowser.addEventAnalytics(CBAnalyticsConstant.USER_INPUT, CBAnalyticsConstant.PAYU_BACK_BUTTON_CLICK.toLowerCase()); payUCustomBrowser.showBackButtonDialog(); } else { payUCustomBrowser.addEventAnalytics(CBAnalyticsConstant.USER_INPUT, CBAnalyticsConstant.MERCHANT_BACK_BUTTON_CLICK); if (CustomBrowserData.SINGLETON.getPayuCustomBrowserCallback() != null) CustomBrowserData.SINGLETON.getPayuCustomBrowserCallback().onBackButton(null); CBActivity.this.finish(); } }