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.
Related
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.
So here's my problem. I made a website, which by popular demand, people want it to be an app on there phone (because apparently people are to lazy to google it and use precious internet :3 )
So I did some research and came across the android webview, and after a few tutorials I got my website working as an app. However this app still needed internet.
So I tried to just put my website files (Which are inside a folder called version) inside the android res folder
WebView/app/src/main/res/
But when I try to access it with the following code
String url = "/res/version/english.html";
WebView view = (WebView) this.findViewById(R.id.webView);
view.getSettings().setJavaScriptEnabled(true);
view.loadUrl(url);
It comes up with the "Webpage not available" message.
Does anyone know how I can fix this. Thanks
My suggestion would be to look into Cardova or PhoneGap. They provide extremely robust tools to program with HTML, CSS, Javascript, etc and then acts as a native bridge between Java or Objective-C if you're developing for iPhone.
You will still have access to many of the core native API's such as Camera, Accelerometer, etc. My company uses these religiously as we mostly have web developers on staff. I would highly suggest it.
I figured out what I did wrong. First off, I needed to add this at the start of it
"file:///"
Then I needed to make an assets folder, and then put all my files into it. And the last mistake, I need to access the access folder by doing this
"file://android_assest/*"
I am trying to build my angularjs app into an android app using PhoneGap Build, but got stucked with the issue of the src of ng-include.
The code below tries to render a html of subheader into the view. It works perfectly in chrome browser, however after I convert the code with phonegap, it does not work. I also tried other path like '../templates/subheader.html' and '/templates/subheader.html', none of them work.
<div class="bar bar-subheader bar-stable" ng-include="'templates/subheader.html'">
</div>
Any suggestions?
It is embarrassing to always answer my own question...
However I finally figured it out.
1. The path inside the ng-include should not have the "/" on its left most.
2. The key of this issue is not the ng-include. It is because I was trying to fetch a variable stored in the $cookieStore:
For some reason I don't know, the data stored in $cookieStore can't persist between page transition. It impact many components in my page. So I have to change the $cookieStore to another local storage service https://github.com/grevory/angular-local-storage.
I had the same problem, that my include was not shown on the device.
But my problem was that I put the template in an folder which's name started with an underscore _.
This is ignored in the build-process. Renaming the folder helped!
Did you have a chance to look at Ionic Framework ? It works on phonegap and has build in AngularJS support. It also has some mobile ready components.
I am trying to link a js file to my android application. If it's possible. To be more specific I am developing an app using HTML(I don’t need help with this part) and I want to get my template working, it has mixed parts of html, css and javascript. This is what I have so far at the head of my sheet. ( I don’t know how to make code appear on here, I do have the < & /> in the original.
link rel="javascript" href="java2/jquery/mobile-slide-menu.js"
script type="text/javascript" src="java2/jquery-mobile-slide-menu.js"
This is what I am trying to make:
http://jsfiddle.net/gh/gist/jquery/1.9.1/5624435/
Is it possible to have html,css and javascript in one page or do I have to link them for them to work.
Let me know if you need more information.
You can do it either way as you are not using the webview javascript bridge directly it does nto matter which way you choose
Your choice will depend on which way you want to keep track of changes in the javascript and html css combination ..separately through different files or one single html file
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).