I have an Activity which is basically a big webview with some other buttons. Normally, I load urls to the webview, and everything works fine. But there is one website, of which all urls are loaded as source files instead of normal html (the browser shows plain text containing the html tags). The strange thing is that using the phone's browser this url loads just fine.
http://pelephone.ynet.mobile1.co.il/default.aspx?N=/ynet/ArticleList.aspx?category=3
Maybe this has something to do with the aspx file? in my laptop computer the url is not loaded, but downloaded as a file. but still, the phone's browser handles it just fine.
Thanks so much for your help!
It's definitely an issue with the URL, or in general with WML URLs.
The mime type of the supplied URL is "text/vnd.wap.wml". Android does not support that,
it displays the source of such pages as plain text. You can find the relevant piece of code
} else if (mMimeType.equals("text/vnd.wap.wml")) {
// As we don't support wml, render it as plain text
mMimeType = "text/plain";
in git://android.git.kernel.org/platform/frameworks/base.git/core/java/android/webkit/LoadListener.java (line 375).
So that's the correct framework behavior (which applies to WebViews).
Im not sure why the browser displays that, basically it should not, and does not here (Tested with an 1.6. and 2.3 emulator and my 2.2. HTC desire). Are you sure your browser is stock? Maybe you are using an alternative browser such as Opera. Or your provider/manufacturer added some wap support for their "premium-content" (if your phone is branded and/or has custom stuff like sense).
Related
Executive summary: can't display a pdf file on Android Firefox.
I created an HTML page on my laptop and displayed it using Firefox. The page is a simple menu, consisting solely of links to my wife's sewing machine manuals, like so (skipping over header, title, and stuff, no css, not xhtml):
<p><ul>
<p>
<p><li><a href="file:///storage/3C5D-4F8A/Manual/thing.txt">
<strong>Thing
</strong></a></li>
</p>
<p><li><a href="file:///storage/3C5D-4F8A/Manual/overlockbasics.pdf">
<strong>Overlocking Basics
</strong></a></li></p>
<p><li><a href="file:///storage/3C5D-4F8A/Manual/allaboutthread.pdf">
<strong>All About Thread
</strong></a></li></p>
</p>
...and so on. The goal is to have the manuals handy to the sewing machine. The phone is handy.
On a laptop, clicking the link pops up the associated pdf file, which is expected behavior. However, when I put the HTML file on her phone (and after adjusting the file paths), clicking a link returns a 'unable to download file' message.
To insure I had the correct path at least, I put that 'thing.txt' link in; clicking that returns the contents of the thing.txt file ("This is a thing", if you were wondering), so the path as specified seems correct, and that at least the text display 'plugin' works.
Tried attaching a 'type="application/pdf"' to each anchor tag, but that had no effect. From what I've discovered, Firefox is supposed to have a built-in PDF viewer - a sensible notion - although I have a suspicion that it only works with downloaded files...but if that's true, why does it work on the Win10 laptop? Inquiring minds want to know. True, there are some differences between the two platforms, so perhaps that's just the way things are.
To reiterate, the files I'm trying to display are right there on the phone's storage card.
The phone is a Galaxy S5 sport (android version 6.0.1); Firefox version is 68.3.0.
The laptop is Win10, Firefox version is 71.0.
I see that other people have had problems sort of like this, but their issues appear more complex. This does not seem to be complicated, aside from the common not-working part.
If someone can suggest a solution that doesn't involve third-party add-ons, or reconfiguring Android, or dragging Google into the process, (or as someone suggested elsewhere, writing one's own browser), it's appreciated. Prefer someone pointing out what I'm doing wrong. It's entirely possible that something so simple cannot be simply done.
To see what happens on a Raspberry Pi (mainly because it was handy), I mounted the Samsung as a mts device, modified each anchor tag's path to a single dot/slash preceding the PDF file name, and ran the HTML file into both Firefox ESR, and then Chromium. Oddly, both browsers spontaneously opened and populated tiny PDF windows corresponding to each href; no link click was required. So all that demonstrated is that Firefox behaves differently depending on the platform; I'm glad you were all sitting down for that revelation. Still, it was interesting, in that those browsers had no trouble displaying something. Note I'm not complaining about that; it was just an experiment.
To recap - main interest: Firefox on the Android not displaying PDF when anchor tag clicked.
Thanks.
Haxeflixel android targeting.
I need open text string with SVG syntax (XML) in default android browser, without server request/response actions. Something like just pushes text variable to the browser and display it as SVG file, like in the case when I do request and server response me SVG, but without internet and without creating the SVG file in the system storage (need additional permissions... in time of install apk...).
Is it possible?Any help will be good.
An actual browser window does not allow that, so I think what you want is a WebView. It uses the default Android browser engine and is what you see in most apps.
Since you are using HaxeFlixel and it, in turn, is based on OpenFL, you can use its extension-webview native extension:
var htmlString = <...>;
extension.webview.WebView.openHtml(htmlString);
You can also specify a onClose callback.
Note: it might be necessary to wrap the SVG in some HTML.
Ok, there's a long history behind this one, but the gist is that we need to create and download a little bit of text CLIENT side, into a file called "test.lbl". Assume we can't access the server side.
The following code (coffeescript) does this by creating a Blob, converting it to a data url, and then clicking the link. This works GREAT in a desktop Chrome browser. However, in Android Chrome (not sure what version exactly, but I just installed it as of 3/5/13 from Google App Store) this simply won't work. In Android Chrome, the file starts to download and then just spins. (In fact, it shows in your "Ongoing" for quite some time, even after the browser is closed.)
Anyone know why this might not work in Android? Perhaps a different mime type will make it allow the file to be downloaded? We're dealing with internal tablets so we can relax any site specific security settings we need to.
Or, is there a better way to go about this entirely? (client-side generated text file download)
Thanks
$("#get-label").on 'click', (e) ->
e.preventDefault()
bb = new Blob(['test test test'], {type:'text/plain'})
evt = document.createEvent("HTMLEvents")
evt.initEvent("click")
$("<a>", {download: 'test.lbl', href: webkitURL.createObjectURL(bb)}).get(0).dispatchEvent(evt)
This is a known issue in Chrome for Android. I have raised an issue https://code.google.com/p/chromium/issues/detail?id=181032 - if you star that you will be able to see all the updates for it.
I'm serving up a .ePub file for download without displaying the url to the client. The code below works in any browser on a PC/Mac but will not work in mobile browsers, at least in Android which is what I have for testing currently. I get a 'download unsuccessful' message every time. Any ideas???
Code:
<cfheader name="content-disposition" value="attachment;filename=#authStuff.lastname#-#theTitle#.ePub" /><cfcontent type="application/unknown" file="d:\home\sample.net\bookSource\#book.ePub#">
all the examples I've seen and used ave a space between the attachment; and the filename, so you could try:
<cfheader name="content-disposition" value="attachment; filename=#authStuff.lastname#-#theTitle#.ePub" />
Also, use FireBug or Fiddler to make sure the header is coming through unaltered. Do desktop browsers prompt you to save with the right filename?
EDIT: Just tried your code out on ios with a pdf and that happily consumed the pdf, so the space may be a red herring, however it makes me think it's probably worth trying out the code below to try to see if it's an ePub thing or a headers thing:
<cfheader name="content-disposition" value="attachment;filename=something.pdf" />
<cfcontent type="application/unknown" file="#expandpath('something.pdf')#">
Try making the following two changes to your code:
1) Wrap the content-disposition filename in quotes (either using doubled up quotes to escape them, or #Chr( 34 )# so they're not confused with your value attribute quotes).
2) Use application/octet-stream as the content type (should really be application/epub+zip but Android doesn't seem to recognize it).
This seems to work on Android 2.3.5 at least.
<cfheader name="content-disposition" value="attachment; filename=#Chr(34)##authStuff.lastname#-#theTitle#.ePub##Chr(34)#">
<cfcontent type="application/octet-stream" file="d:\home\sample.net\bookSource\#book.ePub#">
I was trying to display a webpage of a url on a plain WebView, and some of the images are not showing. However, everything shows up fine in the browser for the simulator.
Is there a difference between the rendering via WebView vs. the Android 2.3 Browser?
There are several things added to the Android browser. They add things in to handle JavaScript, to handle switching to native functionality for videos, etc. Luckily the Browser is open source so you can get the Android code base and see what they do.
Yes could be a difference. If you are passing the web text-plain to the webview directly it doesn't understand the images which are references depending the local path instead the goblal path reference.
I mean, if you have a <img src="/images/image.png" /> here you are referencing depending on your directory, and the browser try to look up image.png into your root, and if you have <img src="http://www.whatever.com/images/image.png" /> then you are referencing it globaly. So I think this is the main that you could have.