Accessing external website from PhoneGap application

To create a PhoneGap application, To load external webpage into android application by following the instruction.

Steps:

1) Create phonegap application and configure with android.

2) Then open your activity file and make the changes, onCreate() method is calling super.loadUrl(“http://your-domain.com”); so that http://your-domain.com page is opened in the WebView as soon as application starts

super.loadUrl(“file:///android_asset/www/index.html”); change to super.loadUrl(“http://your-domain.com”);

3) Now it will load external website in android application.

Sample code for your reference:

[java]
import org.apache.cordova.CordovaActivity;
import android.os.Bundle;

public class RssFeed extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.setIntegerProperty("loadUrlTimeoutValue", 70000); // The connection to the server was unsuccessful. URL=http://your-domain.com, 7000 Milliseconds which equals 7 seconds.
super.setStringProperty("loadingDialog", "Loading…"); // Loading screen until the web page load
super.loadUrl("http://your-domain.com");
}
}
[/java]

Permanent link to this article: https://blog.openshell.in/2014/01/accessing-external-website-from-phonegap-application/

Leave a Reply

Your email address will not be published.