I want to make a simple android application that uses webview for displaying a specific website. Since the app shouldn't open to no connection even in offline mode I want to save the cache first time and show it later. But using myWebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); this code only saves simple html files. The website i am using is in php. So it's not working, isn't there any way just the html part of the php page can be saved.
You can download the html to file storage and load it using iframe. If the app is in offline you can take the data from file storage. In this case your css and js have to be inlined to the page.
https://github.com/gregko/WebArchiveReader
How do I save a complete webpage displayed in Android's WebView?
Related
I am using mysql database, i have a web site. So now i decided to create a mobile application. But i have some image in ftp, and their path saved as a varchar in mysql.
I connect to mysql remotely in Android app. But i dont know which is the best way to show image on Android app.
I have 2 way to show it. First one is i can get an image path and show on an url in image view or the other one is i saved that images blob file in mysql and get the base64 encoded text and show. But which is the better way ?
Google has released an awesome library that handles HTTP requests and its main purpose is literally simplify developers life when they need to manage a huge amount of web requests, providing image caching solutions and avoiding the problems of concurrent programming, thread syncronization etc...
I'm talking about Volley
This great solution is exactly the solution to your problem, why? It's because it exposes a clear way to request remote image resources and caching them directly inside the app storage, without the inconvenient of using mobile network each time you open the app, refresh a fragment/activity or add a new element to a listview object.
This is done by implementing an image request method.
So, I think you should store your images on disk and save just their path inside the database, and then, from the app, make a request to your server, Volley will take care of getting the image and raising a callback when the request has been completed.
Simple and clear.
I created an app using PHP and it runs fine using the HTTP address in the Webview object.
When using locally, the PHP script does not work (putting all files in assets).
Is there a way for PHP pages to be loaded locally but to define the actual PHP part to be used at the webserver?
To clarify, all HTML content of the .php page will be used locally but when needed PHP code it will connect the webserver.
Thanks!
If you use a php content you should have Internet connection because php codes work on server side not local devices(some apk's install mysql+php in your android device but if you want to publish your apk this way wont work in all devices on local.)
Also if you want to make an offline project why dont you use javascript "To clarify, all HTML content of the .php page will be used locally"
Here you can download phpforandroid.apk to work on the local Click Here
I know I can use something like file_get_contents to save a web page's source locally, and I know how to manipulate the text of it. But what if the web page has JavaScript that dynamically generates content? How can I download the fully rendered page source?
You need to pass the data through a rendering engine. The simplest option is to programmatically control a web browser. Libraries that will help you do that include Selenium and php-phantomjs.
I am new in PhoneGap,
I have a Joomla Site, I want to create a PhoneGap App using that Joomla site. so is this possible ? if yes than how can i implement it ?.
You can use. But you have to create web services for request and responses. Because Phonegap will not run PHP script. So you can create webservices to access Joomla functionality via JSON responses from your joomla. You can get the JSON data via jQuery in your phonegap app.
and someone said PGBuild will convert webpage into phonegap app. You can try it also.
I have succeeded creating an application as follows:
Design your Joomla page so it's responsive and renders correctly on your mobile;
Download the whole thing with wget
Edit all urls and make them point to the right (local-remote) locations.
I saved all css, images, js locally so the page would load even offline; then changed all the links so they point to the remote host;
All forms should point to the remote host;
Most modules and components were changed so after the initial display (local) they will load the updated info in the frame.
Popups won't be available, so you'll need heavy workarounds for facebook integration etc.
Also, if you plan to use any phonegap features, they will only be available if you load the library inside your downloaded page; this will force you to change all calls to ajax (no document.location.href calls are possible since you'll lose the phonegap javascript).
The first time you load the page from the server it will take forever to load. Ensure you have proper caching set up otherwise you'll just lose your customers.
My advice is to start with an ajax project at the very beginning, it will save you lots of headaches.
Keep in mind, if you plan to use iframes, forget it. They work lousily on iphones, and debugging is nearly impossible. Simply take your time to plan a real phone app in javascript & using Ajax for the calls.
You don't need any webservices in Joomla for loading content, simply use:
&tmpl=component
when you need the content of a module.
Additionally, for blogs and lists, Joomla makes RSS feeds available so you shouldn't need too much coding to achieve this.
I have limited myself to ajaxifying the modules, which makes caching more efficient on the server and the interfaces appear more dynamic.
I am working on a project and was wondering how the code for downloading video files is like. I have an idea but it is half of the bigger picture.I am coding in php and jquery.
Simply link to them in either PHP or jQuery and then visitor to the site can click to download them; this is complicated by the server/client model of served pages, in that you're trying to get the client to download the videos, not the server.
Also, if their default viewer is something like Windows Media Player, this will manage the downloading for you/them.
Unless you're talking about embedding the video into the page and streaming the content when the page loads, or an event is fired (jQuery, etc)?
Hope this helps.