Closed ghost closed 4 years ago
Shubham, Please create a inner Fragment class inside PaymentsActivity class and extends that fragment with Bank.class. Replace all method as mentioned in the example. It will work.
public static class MyBank extends Bank{
@Override
public void registerBroadcast(BroadcastReceiver broadcastReceiver, IntentFilter filter) {
mReceiver = broadcastReceiver;
getActivity().registerReceiver(broadcastReceiver, filter);
}
@Override
public void unregisterBroadcast(BroadcastReceiver broadcastReceiver) {
if (mReceiver != null) {
getActivity().unregisterReceiver(mReceiver);
mReceiver = null;
}
}
@Override
public void onHelpUnavailable() {
getActivity().findViewById(R.id.parent).setVisibility(View.GONE);
getActivity().findViewById(R.id.trans_overlay).setVisibility(View.GONE);
}
@Override
public void onBankError() {
getActivity().findViewById(R.id.parent).setVisibility(View.GONE);
getActivity().findViewById(R.id.trans_overlay).setVisibility(View.GONE);
}
@Override
public void onHelpAvailable() {
getActivity().findViewById(R.id.parent).setVisibility(View.VISIBLE);
}
}
make receiver as static. Thanks, Junaid
Hi, I have created class "public static class MyBank extends Bank{...}" inside PaymentsActivity and done changes in code above in PaymentsActivity Class.forName("com.payu.custombrowser.Bank"); final MyBank bank = new MyBank() {...}
have i done right ? still it is giving me error ! please help
I have attached files and error code bellow. please help urgently.
D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=7649, _sc=PayUNetBankingActivity, _si=9078936444052808821}]
V/FA: Using measurement service
V/FA: Connection attempt already in progress
V/FA: onActivityCreated
I/WebViewFactory: Loading com.google.android.webview version 54.0.2840.85 (code 284008500)
I/art: Rejecting re-init on previously-failed class java.lang.Class
I am also getting same error. Please Help
Fragment null must be a public static class to be properly recreated from instance state.
11-30 15:16:38.350 16992-16992/br.towness.ndrawer W/System.err: java.lang.IllegalStateException: Fragment null must be a public static class to be properly recreated from instance state. 11-30 15:16:38.351 16992-16992/br.towness.ndrawer W/System.err: at android.support.v4.app.BackStackRecord.doAddOp(BackStackRecord.java:435) 11-30 15:16:38.351 16992-16992/br.towness.ndrawer W/System.err: at android.support.v4.app.BackStackRecord.add(BackStackRecord.java:420) 11-30 15:16:38.351 16992-16992/br.towness.ndrawer W/System.err: at com.payu.payuui.PaymentsActivity.onCreate(PaymentsActivity.java:166)
This problem is happening with old PayU sdk
I got new sdk version from PayU tech team. Try this
https://github.com/payu-intrepos/Android-SDK-Sample-App/releases/tag/s4.4c6.1.1m1.0.4
I am Facing this issue . AndroidRuntime: FATAL EXCEPTION: main Process: com.signity.bamboofoodz, PID: 28715 java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.app.Activity.findViewById(int)' on a null object reference at com.payu.custombrowser.Bank.onPageFinishWebclient(Bank.java:694) at com.payu.custombrowser.PayUWebViewClient.onPageFinished(PayUWebViewClient.java:73) at com.android.webview.chromium.WebViewContentsClientAdapter.onPageFinished(WebViewContentsClientAdapter.java:196) at org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:70) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Working Code: update the CustomBrowser-release then Working fine. /* try { Class.forName("com.payu.custombrowser.Bank"); final Bank bank = new Bank() { @Override public void registerBroadcast(BroadcastReceiver broadcastReceiver, IntentFilter filter) { mReceiver = broadcastReceiver; registerReceiver(broadcastReceiver, filter); }
@Override
public void unregisterBroadcast(BroadcastReceiver broadcastReceiver) {
if(mReceiver != null){
unregisterReceiver(mReceiver);
mReceiver = null;
}
}
@Override
public void onHelpUnavailable() {
findViewById(R.id.parent).setVisibility(View.GONE);
findViewById(R.id.trans_overlay).setVisibility(View.GONE);
}
@Override
public void onBankError() {
findViewById(R.id.parent).setVisibility(View.GONE);
findViewById(R.id.trans_overlay).setVisibility(View.GONE);
}
@Override
public void onHelpAvailable() {
findViewById(R.id.parent).setVisibility(View.VISIBLE);
}
};*/
/* Bundle args = new Bundle();
args.putInt(Bank.WEBVIEW, R.id.webview);
args.putInt(Bank.TRANS_LAYOUT, R.id.trans_overlay);
args.putInt(Bank.MAIN_LAYOUT, R.id.r_layout);
args.putBoolean(Bank.VIEWPORTWIDE, viewPortWide);
args.putString(Bank.TXN_ID, txnId == null ? String.valueOf(System.currentTimeMillis()) : txnId);
args.putString(Bank.MERCHANT_KEY, null != merchantKey ? merchantKey : "could not find");
PayUSdkDetails payUSdkDetails = new PayUSdkDetails();
args.putString(Bank.SDK_DETAILS, payUSdkDetails.getSdkVersionName());
if(getIntent().getExtras().containsKey("showCustom")) {
args.putBoolean(Bank.SHOW_CUSTOMROWSER, getIntent().getBooleanExtra("showCustom", false));
}
args.putBoolean(Bank.SHOW_CUSTOMROWSER, true);
bank.setArguments(args);*/
// findViewById(R.id.parent).bringToFront();
/* try {
getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.fade_in, R.anim.cb_face_out).add(R.id.parent, bank).commit();
}catch(Exception e)
{
e.printStackTrace();
finish();
}
mWebView.setWebChromeClient(new PayUWebChromeClient(bank));
mWebView.setWebViewClient(new PayUWebViewClient(bank){
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
Log.e("Should overriding", url);
if (url.contains("payUMoneyReturnURL?") && url.contains("status")) {
String payment_request_id_value = null;
String payment_id_value = null;
String status_value = null;
try {
String[] separated = url.split("payUMoneyReturnURL?");
separated[1] = separated[1].trim().substring(1, separated[1].trim().length());
String[] separated1 = separated[1].split("&");
String payment_request_id = separated1[0];
String[] payment_request = payment_request_id.trim().split("=");
payment_request_id_value = payment_request[1];
String payment_id = separated1[1];
String[] payment = payment_id.trim().split("=");
payment_id_value = payment[1];
String status = separated1[2];
String[] aStatus = status.trim().split("=");
status_value = aStatus[1];
if (status_value.equalsIgnoreCase("success")) {
Intent intent = new Intent();
intent.putExtra("payment_request_id", payment_request_id_value);
intent.putExtra("payment_id", payment_id_value);
setResult(2, intent);
finish();
} else if (status_value.equalsIgnoreCase("error")) {
Intent intent = new Intent();
setResult(3, intent);
finish();
}
else {
Intent intent = new Intent();
setResult(3, intent);
finish();
}
} catch (Exception e) {
e.printStackTrace();
Intent intent = new Intent();
setResult(3, intent);
finish();
}
}
return true;
}
});
*/
mWebView.setWebChromeClient(new WebChromeClient());
mWebView.setWebViewClient(new WebViewClient());
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.postUrl(url, uri.getBytes());
During testing the test android application, whenever we continue to pay via PayuBiz. Android application suddenly crashes: following is the error log:
09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: java.lang.IllegalStateException: Fragment null must be a public static class to be properly recreated from instance state. 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at android.support.v4.app.BackStackRecord.doAddOp(BackStackRecord.java:435) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at android.support.v4.app.BackStackRecord.add(BackStackRecord.java:420) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at com.payu.payuui.PaymentsActivity.onCreate(PaymentsActivity.java:166) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at android.app.Activity.performCreate(Activity.java:5231) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at android.app.ActivityThread.access$800(ActivityThread.java:135) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at android.os.Looper.loop(Looper.java:136) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5017) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at java.lang.reflect.Method.invokeNative(Native Method) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at java.lang.reflect.Method.invoke(Method.java:515) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 09-12 04:23:10.299 25470-25470/com.payu.testapp W/System.err: at dalvik.system.NativeStart.main(Native Method)
09-12 04:23:14.439 25470-25470/com.payu.testapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.payu.testapp, PID: 25470 java.lang.NullPointerException at com.payu.custombrowser.Bank.onPageFinishWebclient(Bank.java:694) at com.payu.custombrowser.PayUWebViewClient.onPageFinished(PayUWebViewClient.java:73) at com.android.webview.chromium.WebViewContentsClientAdapter.onPageFinished(WebViewContentsClientAdapter.java:449) at com.android.org.chromium.android_webview.AwContentsClient$AwWebContentsObserver$1.run(AwContentsClient.java:73) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5017) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) at dalvik.system.NativeStart.main(Native Method)
Kindly look into the error