Accessing external website from PhoneGap application

I wanted to create a PhoneGap application, which instead of pointing to a HTML page inside the application should open my blog site http://wpcertification.blogspot.com these are the steps that i followed to build the application, you can download it from here
  • I followed the instructions in Getting Started with Android to build application that points to index.html inside the application, i tried it once to make sure that it works
  • Then i changed the HelloCordovaActivity like this so that it points to http://wpcertification.blogspot.com
    
    package com.webspherenotes.cordova.sample;
    
    import org.apache.cordova.DroidGap;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    public class HelloCordovaActivity extends DroidGap {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            super.loadUrl("http://wpcertification.blogspot.com");
        }
    }
    
    The onCreate() method is calling super.loadUrl("http://wpcertification.blogspot.com"); so that http://wpcertification.blogspot.com page is opened in the WebView as soon as application starts
  • The default configuration of the PhoneGap application disallows opening of any external URL so i had to change the cordova.xml like this to allow access to http://wpcertification.blogspot.com
    
    <?xml version="1.0" encoding="utf-8"?>
    
    <cordova>
     <!--  
     access elements control the Android whitelist.  
     Domains are assumed blocked unless set otherwise
      -->
    
        <access origin="http://127.0.0.1*"/> <!-- allow local pages -->
     
     
     <access origin="http://wpcertification.blogspot.com" />
     
     
     <!-- <access origin="https://example.com" /> 
     allow any secure requests to example.com -->
     <!-- <access origin="https://example.com" subdomains="true" /> 
     such as above, but including subdomains, such as www -->
     <!--  <access origin=".*"/>   
     Allow all domains, suggested development use only -->
    
        <log level="DEBUG"/>
        <preference name="classicRender" value="true" />
    </cordova>
    
    Take a look at XML comments in this file for syntax on how to allow access to external URLs
Now the application is ready and when i launch it i can see my blog being opened like this

13 comments:

Unknown said...

why "" error "Description Resource Path Location Type Attribute is missing the Android namespace prefix"

Bangaloreweb guru said...

I am a regular user of your post, this one also was very interesting and well written. keep sharing the great work Web Design Agency in Bangalore | Website Developers in Bangalore

Unknown said...

Nice post and great content.
Avast Customer Support is here to help you out with the whole procedure to Download Avast Antivirus online, We not only fix your Avast Support related issues but will guide with how to get started with your new Avast product once it gets installed successfully. We at Avast Tech Support provides service to protect your PC from potential online threats and external attacks like viruses, Trojans, malwares, spywares and phishing scams. And Avast Refund. Call on our Avast Phone Number

Gmail Customer service is a third party technical support service for Gmail users when they face any technical issue or error in their Gmail account. Our Gmail Customer Support team solves issues like forgot Gmail account password, Gmail configuration or Sync issues, recover deleted emails and many more. Toll Free number (800) 986-9271

How you install or reinstall Office 365 or Office 2016 depends on whether your Office product is part of an Office for home or Office for business plan. If you're not sure what you have, see what office com setup products are included in each plan and then follow the steps for your product. The steps below also apply if you're installing a single, stand-alone Office application such as Access 2016 or Visio 2016. Need Help with office setup Enter Product Key? Call 1-800-000-0000 Toll Free
Norton Tech Support is a third party service provider and not in any way associated with Norton or any of its partner companies. We offer support for Norton products and sell subscription based additional warranty on computer and other peripheral devices. Call our Toll Free number 1 855 966 3855
Other Services
Norton Toll Free , Office-Setup , office.com/setup.

Designpluz said...

Great list. I know many of them, but have now bookmarked several new ones. Thanks!I like This Blog Posting. I Will Recommend This Post to Our Friends.Web Design Sydney, Logo Design Sydney

Unknown said...

It is really interesting for me to read this article. Thanks for it. I like such topics and everything connected to them.
SEO Experts in Bangalore

Best SEO Company in Bangalore
low cost seo packages

Anonymous said...

We help in setting up and Installing Microsoft Office on your computer. We provide Technical Support and other services to you. We help you with great work and other details. We are here to help you. We help you with Microsoft Office and Office installation. We help you with Great technical services at an affordable price.
visit:- www.office.com/setup

scoot said...

THANK YOU FOR THE INFORMATION
PLEASE VISIT US
Web designing company in Bangalore




abhi said...

Nice blog Thank you

web design company in bangalore

website design company in bangalore

best web design company in bangalore

bestdesigninfotech said...

Thanks for sharing the post. Keep updating web design services
web design company

Cyanous said...

Well explained…great work…thank you so much for sharing such a valuable information. Looking for the best phonegap app development services in Hyderabad Contact Cyanous software solutions now.

Best phonegap app development services in Hyderabad
Best software & web development company in Hyderabad

Cyanous said...
This comment has been removed by the author.
Cyanous said...

Clear cut explanation. Am pretty much impressed with your explanation. Looking for the best phone gap app development services in Hyderabad, India? Contact Cyanous software solutions now.

Best network penetration testing services in Hyderabad
Best software & web development company in Hyderabad

George said...

As the world has evolved, our needs have changed. We're no longer satisfied with a website that captures our attention for a few minutes; we want an app that keeps us engaged for hours. When you consider the fact that most people spend more time on their phones than they do with their families, it's no wonder thatmobile appsare becoming a more common part of any business plan. In other words, if you're not designing apps, you could be missing out on hundreds of thousands of dollars—if not millions.