PhoneGap Application reading remote html content - android

Can I develop hybrid application using phonegap which reads html content at runtime from remote location?
If yes, will it work for both Android as well as iOS?

Yes, this is very easy to do on Android and the comment above provides one way to do it. Another is to make AJAX request for the HTML you want and inject it into your page. However Apple will not like this even though it is technically possible. You are better off requesting data via AJAX and then displaying the data in your app rather than pulling down pure HTML.

Related

Can I make an android app using html that recieves and stores values entered by the user?

Basically, I'm trying to make use of this website called PhoneGap that recives html codes and converts them into mobile applications.
So I'm trying to make an application that tells you how much money you owe people and how much money people owe you.
IS this possible?
HTML alone isn't enough to develop your application. It's a simple mark-up language and unable to create any real functionality. But HTML if used together with javascript (which adds the required functionality) will work great for building what you mentioned.
So if, for any reason, you'd prefer to not develop a standard native application (one which is installed locally on a user's device), then another option is to build a web-based application. These have much in common with typical websites (though optimized for mobile devices) and are generally easier to build. Another advantage is that they can run on almost any device that has a browser installed, and therefore not tied to any one specific OS, such as Android. Web applications - despite not being installed on the user device - can none the less make use of local storage to save data. This is one example for when javascript is needed.
Here is a great resource for learning about javascript: http://www.w3schools.com/js/
You should read about HTML5 and hybrid apps. A hybrid app is what you are after.
Yes, you can use html to build an app with Phonegap, but you'll need JavaScript too.
I suggest the following technologies for you: Ionic, Angularjs and localStorage for recording the data.

webscraping using Phonegap

I need to build a cross-platform app (IOS + Android) that requires some web scraping capabilities. What I need it to do is to login on certain sites, grab the relevant information and present a combined overview of data from these sites.
So is there any way to accomplish web scraping in phonegap?
It's easy, just use Ajax to request a page.
Use something like JQuery to make the Ajax easier to work with.
Use JavaScript's regular expressions to extract what you want from the Ajax response. You could also use a Dom parser library of some sort as well for more direct access.
Make sure you have your PhoneGap config set up correctly for making Ajax requests. See AJAX Request from Phonegap Android fails

Communicating to the restful web services in Phonegap

I want to built a mobile application using Phonegap that will communicate with the restful web services and parse the json data.There are two ways two do it:
Calling restful web services using http connection in Java and connecting the Java code to JavaScript file by making our own plug-in in cordova.
2.Making ajax calls to communicate with rest services.
Which one is better considering the needs below:
1.It can call https web service,since for https in android we need to include certificates,create bks file for that which includes lot of mess.
2.It should be able to receive and parse the json data and render it to the html page.
3.We need to built this app for primarily android OS but if we can built it for ios,windows etc. It would be better.
Please tell me if i am using right tool,if sencha touch is easier to perform these tasks?
I would suggest that you use AJAX because it completely fits all your needs, and you gain to use the same code for future use if you'll ever decide to build for more platforms.
moreover, why make things complicated? you already writing your app using javascript, so don't mix it with native code when its unnecessary.
The fact that you choose PhoneGap, it is an indication that you are wanting to re-use your HTML/JS/CSS expertise as much as possible. Say if you choose jQuery Mobile (or any other framework) for your project, jquery provides ajax for your needs already and there is no reason to go down to the JAVA layer.
That said, the right approach should be using the ajax mechanism provided by your javascript framework. This is your option-2 and you won't need to build the raw ajax utilizes. Like if you go with jQuery/jQueryMobile + Backbone + backbone.marionette (we happen to use them in phoneGap app), there are a lot of add-ons out there to help. Like in this example, it is actually part of the phoneGap app under 'www' directory.
Also the communication to the webservice is your least concern if you have all the tools. Making suggestion on what tools to use is not allowed by Stackoverflow:-)

Where to keep html pages for mobile app built with Phonegap?

I'm building a mobile app for Android and iPhone using Phonegap. I was planning to keep all html, css & js files on my web server and serve from there only using webview. I am confused about it. Is it possible to do that or do I have to bundle with Phonegap? I have also seen this but this post is one year old. Are there any changes?
Please provide your views.
Thanks
Bhupinder
You are far better off packaging the resources (html/css/js) with the app. If you load everything remotely you are risking: A) being rejected by at least Apple's app store and B) network latency causing your app to be unusable.
You can absolutely do this. you can load css, js and html from server. But it almost look like a mobile website and more over you cannot control the pages with your phonegap events like sensors, battery and notifications, etc., It is purely like a website only. If your net is fast, definitely page loads also fast from loading web server. The main point is you cannot interact users with your app like normal android apps. you can just use like a mobile website. So what i prefer is loading from mobile as package is better and it gives a real application experience rather than a website.
Yes, you can do it but it will be rejected by the apple app store first. Also in case of network failure or slow internet connection, your application will be of no use. So i suggest to avoid this as this will be a mobile application, not the website.

Android: Creating Formatted Native Android Application that takes Web Content

I'm trying to code a native android application that takes certain parts of a webpage and displays it. Basically I would want a search bar and several other things, so that I can have a clean fitted display on a mobile device. It is the same idea as the Facebook application, I am trying to create a stripped down version of a webpage.
I know how to download a full webpage using a WebView, but how can I take only certain parts of that webpage and display that instead?
EDIT: Is there any way to do this using just java and java-based api's?
(I am writing the application in native JAVA)
Best,
Aneem
It sounds to me like you effectively want to do 'web-scraping'.
I've done this by using an HTTPClient to pull a web-page which I then processed with HTMLCleaner to produce an XML document. I could then drill down through it to extract the various elements I needed (tables mostly).
You'll need to reverse-engineer the web page using the 'view source' capabilities of a web browser.
Be aware though that unless you have total control of the web page source, web-scraping is generally not a great way of producing a stable and extensible app. All it takes is for a re-design of the web page by whoever maintains it and it will potentially break your app completely forcing you to rewrite your HTML processing code.
EDIT: Actually, on the subject of the Facebook app - this isn't the same thing. There are published APIs for accessing Facebook which don't involve accessing the normal Facebook pages. The Facebook app is a 'native' Android app not a web app.
Its not sure from your question if your back-end has web api's implemented via REST, SOAP, whatever. If it does then you'd just use the necessary pieces widgets and all to implement your android application.
If it doesn't then there may not be a direct way to implement what you want. So I'd suggest looking into the back end first before looking at this aspect.
However, you might want to look at PhoneGap if you want to implement a cross platform solution.

Categories

Resources