I have a task to access whole HTML project (with CSS, etc.) in my android project. Can anyone help me on that? I googled about it, but all I found was "Webview", which I already know.
I a\want to know where I can put the CSS files, html files in my Android project and how can I manage whole HTML project? (i.e. transition from one page to other, etc.) Please suggest me some good document or tutorial if you know about this. If webview is the only way, how can I switch from one page to another? Because all I know is to use
myWebView.loadUrl(Uri.fromFile(www.website.com);
I have also managed to load a single html file from sdcard.
myWebView.loadUrl(Uri.fromFile(
new File(Environment.getExternalStorageDirectory()
.getAbsolutePath() + File.separator + "index.html"))
.toString());
But I don't understand how I can proceed for a whole project!
Any help would be highly appreciated.
You need to use webView that is for sure.
For that you can put you whole HTML (css,js,html) in asset folder and load local index.html in webview just like.
webView.loadUrl("file:///android_asset/html/index.html");
And webview will load whole local site. .css and js will be directly handle by webview it self even hyperlink will also work.
You can also customize you webview and listen js call for making hybrid app. But this is only for hybrid app.
Hope this help.
Related
I have a live website which I want to show in my app with WebView. But also I want to add a css file in my website which will only work if This particular app load the website. Otherwise that css will not work.
Is this possible? If possible please anyone can tell me how to do that?
Put your index.html of your Website and the css file in the assets folder of your Android project. Modify your index.html so it will load the css file by adding a link to it.
Then when loading the WebView, just load the index.html from your assets folder and you are done. Like so: webView.loadUrl("file:///android_asset/index.html")
In my project I have to load the contents of a PDF located in the assets folder onto a WebView.Can It be achieved directly just by reading the contents onto a WebView.. I googled a lot and I found that i need to use third party PDF readers to achieve the same?
If so, Plz give me the links of the source of the PDF reader of GITHUB. Am not able to find it..
If you load pdf inside the webview, unicode text type or images wont be visible. So you want
to go for OCR tool.
Use set of libraries and sdk
This might help you
http://www.qoppa.com/android/pdfsdk/
http://code.google.com/p/droidreader/
mupdf is the best library in terms of performance and all i have found till now, you can also use it in your application.
But it needs knowledge of ndk.
Click here for more description
I surfed a lot for this solution but everywhere I got same solution i.e. either use Intent and pass it to default/installed PdfReader applications, Other one is to use gview from googleDocs to load Pdfs online.
But my question is how can view my pdf offline in webview i.e. if user click on list of pdf in my application don't go to other application or google/gview .
I tried passing assets folder path but not working getting message in webview that "webpage is temporarily down or move permanently."
I also tried this link.. which describes to use pdfViewver.jar but that lib. has it's own issues that needs to be fixed.
any help will highly appreciated
But my question is how can view my pdf offline in webview
You can't. WebView cannot display PDFs on its own.
I want to show a pdf (preferably) or a word document in my app; like a privacy notice screen. Many applications have it, so it should be possible. i tried loading a simple text file as a start but doesn't provide formatting, fonts or trade mark symbols. I've gone through a few posts but I couldn't apply it to my app. Could anyone tell me how is it done? Could I store the file somewhere in res folder and provide a path to open it through my code? I looked into the following link but I'm not sure if that's the right approach in my case android: open a pdf from my app using the built in pdf viewer.
Android does not support opening PDF and DOC files natively. You'd have to make your own implementation.
Like t0mm13b said, you should consider using HTML (+ CSS) instead and use a WebView.
I am developing an Android application in which I have a WebView. I want to save the entire webpage loaded in this webview (Html + all resources + images + icons etc) into a folder and zip it and upload it to a server.
If you use WebView's saveWebArchive, then it is saved in archive format. How do I get the Html and images back from this archive? Is there any documentation for the format of this archive?
If I use addJavaScriptInterface to get the html as described here, I still have to copy the images and other resources from the webview cache dir (/data/data/your app package/cache/webviewCache/). However I did not find webview cache dir (/data/data/your app package/cache/webviewCache/) in Icecream Sandwich.
Is there a way to save the entire webpage displayed in webview along with resources in Android?
Thanks
If anyone is still interested, there is an open source project here that can read WebView's archive format (saved with saveWebArchive) and display it back in a WebView.
https://github.com/gregko/WebArchiveReader
I couldn't find details of the actual format yet.
You can use HTML 5 to store pages in the cache and load from the cache itself.
Caching is easy using HTML5, all you have to do is to make and refer a manifest file that holds information on what all elements need to be cached.
http://www.html5rocks.com/en/tutorials/appcache/beginner/
And here is a good way to implement the cache feature in your webview. http://alex.tapmania.org/2010/11/html5-cache-android-webview.html
Aman Gautam