Android :: How To Mix External / Local Content In WebView?

Oct 12, 2009

I am trying to create a hybrid Android app which pulls HTML content from a web server and renders it in a WebView. However, I also want the external HTML to be able to reference images that are packaged within the android app. I realize that currently it is not possible to do something like <img src="file:///my_image.jpg" /> in the HTML. I have seen discussions of using the ContentProvider to create name spaces in the html, however all of these examples seem to assume that the actual html page is also on the device and tend to use WebView.loadData(). So, is there someway that it is possible to do this? The main goal is to package all the application images/css in the android app, but put the bulk of the application on an external server that returns the actual markup.

Android :: How to mix external / local content in WebView?


Android :: Loading External Data On Local File In WebView

May 27, 2009

when I load external web page, image or javascript file from local webpage. I can't see external image and can't load javascript or webpage. But I can only see local image. Why I can't load external javascript, webpage or image? Here is the HTML source. (of course, I filled right [daum open API key])

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta
http-equiv ="Content-Type" content="text/html;
charset=UTF-8"> <title>Daum 지도 API</title>
<script type="text/javascript"
src="http://apis.daum.net/maps/maps.js?
apikey=[daum open API key]" charset="utf-8"></script> </head> <body>
<div id="map" style="width:600px;
height:400px;
" style="border:1px solid #000">
</div> <img src="http://4.bp.blogspot.com/_2-7AdSkZA7I/RlCnDhD3ZfI/ AAAAAAAAE9U/LEHMtyVLdY8/s400/CutyTale10.jpg">
<img src="file:///android_asset/coffeebean.jpg">
<script type="text/javascript">
var map = new DMap("map", {point:new DLatLng(37.48879895934866, 127.03130020103005), level:2} );
</script> <iframe src="http://www.daum.com" width="300" height="150"></iframe> </body> </html>

and I use this Activity source
package bo.my.android.test;
import android.app.Activity;
import android.os.Bundle; import android.webkit.WebView;
public class OpenAPITest extends Activity {
WebView webView;
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView) findViewById(R.id.webView1);
webView.setWebViewClient(new DaumMapClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("file:///android_asset/daummap.html");
//webView.loadUrl("http://www.daum.net");
} }

View 3 Replies View Related

Android :: How To Run Local Web App In Phone Webview?

Aug 5, 2010

Can anybody tell how to run the local webapplication using android webview. I want to run my own webpages in android using web view.

View 2 Replies View Related

Android :: Way To Display Local File In WebView?

Feb 28, 2009

I thought it might be interesting to some developers. Here's a complete working example of ContentProvider for this purpose: http://blog.tourizo.com/2009/02/how-to-display-local-file-in-android. I also found a topic here: http://groups.google.com/group/android-developers/browse_thread/threa. Looks like the topic was closed and I couldn't reply there, so I created new one.

View 2 Replies View Related

Android :: Way To Display A Pic To Local Html In Webview?

Apr 15, 2010

I am developing a small application in Android. I come across a problem, and not sure whether it is possible in Android platform. I have some local html files. There is an Activity contains a webview, which is used to display these local html files. In some cases, I want to display a picture selected from phone into one of these local html files. Is it possible? Has anyone resolved such problem? I appreciate any of your replies.

View 2 Replies View Related

Android :: WebView Unable To Open Some Local Urls?

Nov 10, 2009

I have a WebView that I'm using to open some files stored in the assets/ directory of my project. It works fine for most of the files, but there's one in particular (and I'm sure others I haven't found) that it just will not open.Code...

View 4 Replies View Related

Android :: How To Use Webview.loadUrl / When Html File Is Local?

Nov 2, 2010

How do I open a a local html-page (named, for instance "test.html") in a WebView? where should i keep this keep html page with images in project and how to use Webview.loadUrl(String url)?

View 4 Replies View Related

Android :: WebView For Form Based Local AJAX Application

Feb 18, 2009

I'm thinking of using WebView as a container for "Form" based JavaScript+DHTML applications. This is simple fill-out-forms like you have on the web, but now on mobile like for note taking, order taking, and the like.This is to allow web developers to build the bulk of the application - Javascript will perform validation, computations, etc.On the Java side, I only need to implement database CRUD operations, and a ListView to scroll over the forms.To minimize the learning curve on the JavaScript side, I've been thinking on how to emulate AJAX calls so that the web developers don't need to learn new methods to call on the JavaScript-Java bridge. Of course this isn't possible using XMLHttpRequest, so I'm thinking of adapting JQuery or other Javascript libraries for this purpose.

View 3 Replies View Related

Android :: Content Rendering For WebView

Jul 15, 2009

Can anyone help me to understand how WebView decided which content it can render and which it can't? For example I am inside a webview select a link and if the link sends an XML file I want my application to handle to data instead of WebView, Is this possible?

View 4 Replies View Related

Android :: How To Get WebView Content Into Bitmap?

Sep 9, 2009

I am trying to get the webview's content on a bitmap so that i can save it as a image. But I am unable to so. I am getting the BLACK image save instead. All content is missing. Here is my code:
//create a webview WebView w = new WebView(this);
//Loads the url w.loadUrl("http://www.yahoo.com");
//After loading completely, take its picture Picture picture = w.capturePicture();
//Create a new canvas Canvas mCanvas = new Canvas();
//Draw the Picture into the Canvas picture.draw(mCanvas);
//Create a Bitmap Bitmap sreenshot = Bitmap.createBitmap(picture.getWidth(), picture.getHeight(),Config.ARGB_8888);
//copy the content fron Canvas to Bitmap mCanvas.drawBitmap(mBitmapScreenshot, 0, 0, null);
//Save the Bitmap to local filesystem if(sreenshot != null) {
ByteArrayOutputStream mByteArrayOpStream = new ByteArrayOutputStream();
screenshot.compress(Bitmap.CompressFormat.JPEG, 90, mByteArrayOpStream);
try { fos = openFileOutput("yahoo.jpg", MODE_WORLD_WRITEABLE);
fos.write(mByteArrayOpStream.toByteArray()); fos.close();
} catch (FileNotFoundException e) { e.printStackTrace();
} catch (IOException e) { e.printStackTrace(); } }

View 7 Replies View Related

Android :: Getting WebView Content Or Cookies

Mar 23, 2010

Is there a way to get the current content of a WebView? What about Cookies for a specific host+url?

View 2 Replies View Related

Play Local Swf-file (flash) With Webview?

Sep 9, 2010

I guess webview is the best solution to play a local swf-file (flash). I just get cryptic character in the emulator with this html code in webview.

HTML Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Flash</title>
</head>

[URL]

How can i play a local swf-file when the user click on some kind of link, java or html?

View 10 Replies View Related

Android :: Placing Webview Control In Tab Content?

Oct 18, 2009

When I place a Webview control in the content of a Tab, it is taking over the entire display! I have jacked around with the layout but I can't figure out how to "fit" the control on the tab. Is it possible to do this?

View 6 Replies View Related

Android :: How To Get Current Page Content Of WebView?

Feb 10, 2009

It's easy to get current page's url and title of webkit.WebView. But I could not find way to get page content of WebView.

View 6 Replies View Related

Android :: WebView Content To Fit Display Screen

Oct 5, 2010

I tried WebView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN); but view crashed in 1.6 OS. I calculate scale(webview.capturePicture()) but I cannot set it after page loaded. Is it any working solution for fitting webview content to display (1.6 OS)?

View 2 Replies View Related

Android :: WebView Wrap Content To Fit In Screen

Jan 2, 2010

Is it possible to Load a URL in a webView and resize it to fit the screen. I mean I want to make the WebPage small so that the user doesn't need to scroll.

View 10 Replies View Related

Android :: Playing YouTube Content In WebView

Oct 7, 2010

I have Java and plugins enabled. Why I can play many online flash videos in my webview, but nothing on m.youtube.com works? I would be more than satisfied with a workaround that passes the video to the YouTube application.

View 2 Replies View Related

Android :: Any Listener For When WebView Displays Content?

Oct 31, 2010

Using WebViewClient and/or the WebChromeClient you can get a listener for when the page has loaded, however this is sometimes called before the WebView has any content in it, before it has displayed anything. What would be a efficient method for determining when the WebView has displayed it's content? When I load a page in a WebView, I want to set the scroll to a specific position. It seems that the scroll position cannot be set until the page is loaded and it has an actual content height. So, I have tried two different approaches to determining when the page has finished loading, onPageFinished() from the WebViewClient and also onProgressChanged() from the WebChromeClient.

Both of these tell me when the page has finished loading. However, the problem is that sometimes it is called before the page has been displayed and therefore the page has no height and the scroll call does nothing. I am trying to find a solid way to determine when the page is ready to be scrolled, i.e. when it has its content height. I imagine I could setup a checking loop after it finished loading to keep looking for when the height is available but that seemed like quite the hack. Hoping there is a cleaner way.

View 2 Replies View Related

Android :: Got WebView - In Its Content Is A Phone Number

Mar 6, 2009

I've got a WebView, and in its content is a phone number. I hightlight it and click - voila, taken to the phone app.

Now, all I do is add this code:

CODE:........

clicks no longer work.

View 4 Replies View Related

General :: Playing Local Audio File In Webview App

Feb 3, 2012

When trying to play a local mp3 file included in the APK, nothing happens. However, if I pull an mp3 from the web it works.

e.g.

< a u d i o src="[URL]..." > WORKS

< a u d i o src="01.mp3" > DOES NOT WORK

I tried looking through logs for clues and found this line. I'm not sure if it's relevant or not.

PlayerDriver::isProtectedFile(file:///android_asset/www/01.mp3)

I'm new to Android development, so I can only guess that the file is somehow inaccessible for streaming.

I'd love to get this figured out though. Having to pull the files remotely every time is not a desirable solution.

Some additional info. Either solution works when tested in the browser. The local file problem only arises when I convert it to an app. I'm using PhoneGap build to create the APK.

View 3 Replies View Related

Android : Content Provider Implementation - Original Data Stored On Network Or Local/remote File Systems

Jun 13, 2010

I'm now trying to implement my own content provider. My original data was stored on network or local/remote file systems, so I want to provide data via input stream. I know that client may call ContentResolver.getnputStream to retrieve the input stream to access data. But I don't know how to implement content provider in this situation, I searched the Internet but all the tutorials for content provider are talks about how to expose data that stored on local database. how to expose data that stored on file systems using a content provider? what happened when client call ContentResolver.getnputStream? I want to know how to return an input stream to my client.

View 4 Replies View Related

Android :: Formatting WebView Content (Text Display)

Mar 12, 2010

I am getting some HTML text from a remote server which I am displaying inside a WebView. I need to format the text display and set a font size and color for the WebView. The only way I can think of is: pre-pending the HTML string received with a tag and specify the font information there. What is the correct way to do this?

View 1 Replies View Related

Android :: Save WebView Content For Offline Browsing

Nov 8, 2010

I would like to implement an apps that allow users save the webpage including images. Then the users can view the web page again even there is no network access. However, I found that there is no such related API to do so.

View 3 Replies View Related

Android :: Deactivate Mobile Content From Website In WebView

Nov 8, 2010

My code:
WebView webView = new WebView(this); webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.preisjaeger.at"); setContentView(webView);
The site the I downloaded appears on the Webview, but only the content for mobile devices. How to deactivate the mobile content?

View 1 Replies View Related

Android :: Using Webview Control To Show The Html Content

Nov 15, 2010

I am using the webview control in android to show the html content. But I face a problem that in webview I have to fix the height so thats why if html content contains less data then it wasted the space. Is there any solution to solve this problem that how can I show only same content as html has in the webview without any wasted space please help. following xml i used to draw webview is this right? In this i give fix height to webview. if i am not giving fix height then it will show only 1 line data with scroll.

CODE:.....................

View 1 Replies View Related

Android :: Way To Find Height Of HTML Content Displayed In A Webview?

Apr 8, 2009

My application generates an HTML file which needs to be displayed to the user . For this purpose I'm using the loadData() API provided by Webview. This HTML file is updated every 2 secs & the same is loaded again using loadData() to display the updated values. On reloading the file the Webview starts displaying again from the top of the file causing the user to always scroll down to the location where he previously was. This causes a very bad user experience. To overcome this issue an alternative that I could think of was to split the file to multiple files that can exactly fit in the the screen. For this I need to find the height of the HTML content that can loaded in a web view. From the WebView documentation I found that an API getContentHeight() is provided for this purpose. Although this method returns me 0 on the first attempt. On subsequent attempt it gives me the height of the page that was previously loaded.

View 3 Replies View Related

Android :: Droid Adding HTML Content On A Webview Without Space / How To Fix?

May 5, 2010

I am trying to add an HTML content to a web view. If the words in the HTML content are without spaces then webview keeps that particular word on the same line.I want that content to be wrapped and be on the next line.Is it possible to do that.I am attaching a sample code that can reproduce the issue.

View 1 Replies View Related

Android :: Pause Flash Content In WebView When Activity Isn't Visible?

Aug 7, 2010

I am experimenting with using a WebView to display Flash content inside my activity. Everything is working pretty well, but when the user hits the home key to put the activity into the background, the Flash content keeps running (sound keeps playing, etc)

I have noticed that both the stock Android browser and Dolphin Browser seem to avoid this problem, and properly pause the Flash content when the browsing activity is put into the background.

Ideally I would like a solution that kills the WebView completely if the activity is finishing, but pauses it otherwise (basically copying the default behavior of the browser)

Here is a simple test I put together that loads a game on Kongregate which has some background music:

CODE:..............

I took a look at the latest source for the stock browser, and it seems to be doing something similar (calling pauseTimers/resumeTimers), although I fear the code I have been looking at is out of date, because it is calling functions that don't seem to exist anymore.

I did verify that the call to pauseTimers is working by testing with a simple JavaScript setInterval which updates a counter. Is there something else obvious that I should be trying in regard to Window or View management?

The documentation for the mobile Flash player says:


Flash Player will also automatically pause SWF playback it is not in view or the foreground application, for example when a call is received or alarm goes off, to reduce CPU utilization, battery usage and memory usage.


This seems to be working perfectly in both the stock browser and Dolphin Browser, but not in my app. Any ideas/solutions would be greatly appreciated!

Update: Here is the function we ended up adding to our activity to get this to work. We call it with "onPause" in the activity's onPause function and "onResume" in the activity's onResume function:

CODE:....................

View 2 Replies View Related

Android : How To Assign An WebView Text Content To String Variable?

Oct 14, 2010

Is there any possibility to assign WebView text content to ordinary String variable?if it so.

View 1 Replies View Related

Android : WebView - Not Able To Go Back To My Activity Screen Once The Content Is Displayed

Apr 9, 2009

Step 1: I am subclassing WebView and rendering html content properly. The intial content is very small with a div and image /link This is displayed in a LInear Layout along with a TextView and ListView. That is my first screen/activity of the application.

Step 2: When I click on a link on this webview, it goes through the webViewclient and expands to full screen to fit the content of the requested page.

After Step 2, I am not able to go back to my activity screen once the content is displayed. When I click on the back button to getback to my activity screen close my activity and goes to the phone's applications desktop. (i.e goes out of my application).

Step 3: In order to fix this issue, I stopped setting my own subclasssed WebViewClient. After doing this, the it seems to render the clicked page in a webView as subactivity. Now When I click on backbutton, it goes back to the activity screen. But, the issue now is, I am not catch event when a link is clicked. How can I catch click events in this case.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved