Payment processing infinitely in WebView - android

I have a testing website where PayUMoney payment processing in test mode is working perfect.
I used the same url in webview and also enabled javascript, but the payment is processing infinitely(Loading forever).
Please help me figure out this. Thanks!
public class MainActivity extends AppCompatActivity {
private WebView webview;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webview =(WebView)findViewById(R.id.webView);
webview.setWebViewClient(new WebViewClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setDomStorageEnabled(true);
webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER);
webview.loadUrl("https://gatewaypayment.000webhostapp.com");
}
#Override
// This method is used to detect back button
public void onBackPressed() {
if(webview.canGoBack()) {
webview.goBack();
} else {
// Let the system handle the back button
super.onBackPressed();
}
}
}

I faced a similar situation but finally figured out that the reason behind the long loading is due to the test details getting updated frequently, or the test environment that PayUMoney provides itself is down. Also make sure of the following:
To test the Bolt Checkout in the test mode, you need to change the JavaScript libraries used as-well as use Test Mode key and salt for hash generation.
So while integrating in Test Mode, include the script as shown below in the head section of your payment request page.
<script id="bolt" src="https://sboxcheckout-static.citruspay.com/bolt/run/bolt.min.js" bolt-
color="<color-code>"
bolt-logo="<image path>">
</script>
Once your integration is done and tested on the sandbox, replace the sandbox JavaScript library with the production library provided by PayU.
<script id="bolt" src="https://checkout-static.citruspay.com/bolt/run/bolt.min.js" bolt-color="<color-
code>"
bolt-logo="<image path>">
</script>

Related

Android emulator can't get api data threw website

I have frontend and backend ready and working on localhost. I am displaying the frontend website threw the android emulator:
public class MainActivity extends AppCompatActivity {
private WebView webview;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webview =(WebView)findViewById(R.id.webView);
webview.setWebViewClient(new WebViewClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setDomStorageEnabled(true);
webview.setOverScrollMode(WebView.OVER_SCROLL_NEVER);
webview.loadUrl("http://10.0.2.2:4200/mobile");
}
}
The problem is that emulator can't get the data from database or send request to api to recieve the data so that it's not displayed. How it looks on a website:
Once again the problem is straight with emulator. I tried building the frontend in production mode with no success. This issue looks strange to me because I am just "retranslating" the working website. Maybe I should declare a special permission or sth like that.
Android Studio Error:

WebView remote site and reward videos

I have a simple game developed in PHP. I have loaded the remote site in Android WebView. I want to find out that if user clicks on a FREE life button which is on my remote PHP site, I want to start a reward video on my Android app.
But how can I know whether the user clicked on the FREE life button in my WebView and start the video instantly in my android app?
There is an Android mechanism that alows you to run Android function from javascript:
<input class="button" type="button" value="FREE life" onclick="startRewardVideo('some parameters can be passed to Android from here')">
<script type="text/javascript">
function startRewardVideo(paramFromJS) {
Android.startRewardVideoAndroidFunction(paramFromJS);
}
</script>
now you need class that knows what to do with your javascript:
public class MyJavaScriptInterface {
#JavascriptInterface // this annotation is importatn
public void startRewardVideoAndroidFunction(String paramFromJS) {
//here you need to start showing reward movie
//because this function will be called after webView button click.
}
}
last step is to connect webView with your javascript interface:
webView.addJavascriptInterface(new MyJavaScriptInterface(), "Android");
and of course don't forget to enable javascript for your webView:
webView.getSettings().setJavaScriptEnabled(true);
Hope it helps :) Ask if you have any questions on this.
Here you have full tutorial

"The file must have been renamed, moved, or deleted" warning in Android webview

I have a very basic Android app in Google's Play store. It's basically one window with a webview showing local html content. Most users who download the app have no problems with it. However, a few are not able to use it at all. When they try to open it, they get a warning "The file must have been renamed, moved, or deleted". In other words their phone or tablet can't locate the html files that are packaged together with the app. I can't replicate this problem and have no idea where it's coming from. I wonder if anyone here run into this issue before and resolved it.
For reference, the app design is shown below (nothing special). A bunch of "htm" files is located in "assets". One of them is referenced in the code explicitly - "Contents.htm". There's no css or javascript, but it didn't seem to make any difference as far as this particular error is concerned. This problem is experienced by people outside the US (so far), which may be another clue as to what it could be.
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</WebView>
MainActivity.java:
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class MainActivity extends Activity {
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView = (WebView) findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.loadUrl("file:///android_asset/Contents.htm");
}
#Override
// Detect when the back button is pressed
public void onBackPressed() {
if(webView.canGoBack()) {
webView.goBack();
} else {
// Let the system handle the back button
super.onBackPressed();
}
}
}
One of my users finally traced the problem to the app called WPS office. Indeed, when WPS office is installed on a device, my app stops working. Apparently WPS hijacks internal links within android webviews and tries to open them by itself. There are no obvious settings to change that behavior, but after uninstall everything returns to normal. I hope this bit of information may be helpful to someone someday.
Try this.
WebView browser = (WebView) findViewById(webview);
browser.getSettings().setJavaScriptEnabled(true);
browser.setWebChromeClient(new WebChromeClient());
browser.loadUrl("file:///android_asset/www/index.html");
browser.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
});
I found the solution:
WPS office hijacks all links in any webview. You can build a workaround like this:
Write a Javascriptinterface and every link should call a Android-Function which load the specific Webview-Url
#JavascriptInterface
public void startGame() {
mWebView.post(new Runnable() {
#Override
public void run() {
mWebView.loadUrl("file:///android_asset/www/game.html");
}
});
}
With this workaround everything works fine: You can test the workaround in my app
https://play.google.com/store/apps/details?id=de.devbert.circlecommander

phonegap function not working in webview

I am trying to build a simple app using webview but unable to get phonegap functions working when I use the webview class. If I use "super" then the phonegap function works fine. Excuse my odd vocabulary.
///////////////// JAVA //////////////////////////
public class MainStart extends DroidGap {
HTML5WebView mWebView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CookieSyncManager.createInstance(this);
CookieSyncManager.getInstance().sync();
mWebView = new HTML5WebView(this);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(new JavaScriptInterface(this), "MyAndroid");
mWebView.getSettings().setPluginsEnabled(true);
mWebView.loadUrl("file:///android_asset/www/index.html"); // phonegap function does not work
super.loadUrl("file:///android_asset/www/index.html"); // phonegap function works here
}
}
///////////////// JAVASCRIPT //////////////////////////
function onDeviceReady(){
navigator.notification.alert("PhoneGap is working");
}
the WebView that PhoneGap sets up include a multitude of features which you are not even referencing in your own WebView - like the Javascript bridge - without it there's no way you can call Native code from within your html page!
may I ask why exactly are you trying to re-create your own WebView, instead of just using the standard supplied one?

Hide the URL bar in Android Webkit

This doesn't seem to work in jqTouch or iUI. But I know it's possible because it works on my Droid when I go to deviantart.com . Anyone know how to do it?
Thanks!
Ok, I'm gonna answer my own question here. I added this bit of jQuery...
$(document).ready(function() { setTimeout(scrollTo,200,0,1) });
The timeout appears to be necessary. On my Droid, the document is not yet ready to scroll when the DOMContentLoaded event is fired.
Have you tried firing the function on window.load and on pageAnimation events?
// Hide URL bar when loading the first page
$(window).load( function() {
setTimeout(scrollTo,200,0,1);
});
// ...and on every subsequent request handled by jQTouch
$(document).delegate("body", "pageAnimationStart pageAnimationEnd", function() {
setTimeout(scrollTo,200,0,1);
});
if you are using a webkit i'm assuming that you have created an on create method, create a class below it that looks something like this
private class CallBack extends WebViewClient
{
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
browser.loadUrl(url);
return true;
}
}
declare a webviewclient, and a webview when creating the parent class
WebView browser;
WebViewClient browserClient;
that should keep your app from opening an external browser.
Went through the same problem when i was starting my app project, so I hope this helps

Categories

Resources