I have a string which consumes the html code of a form and I want to show that form in my app and it should also work further as on submit it should move forward to next page.
I used WebView, it just shows the page in a static way. It don't support buttons and DatePicker, so I DONT WANT WEBVIEW.
First off, WebView does support buttons, and you could support a DatePicker either by using an HTML/JS one or by doing something fancy to route a request to the Java side of things. I really suspect your insistence on not using WebView is going to prove unproductive.
That said, sure you should show your HTML in your app without using WebView... you could write your own web control or take another (Firefox is open source as is WebKit on which WebView is based, in fact so is WebView itself for that matter). That's going to be a heck of a lot of work though.
Related
I created a WebView (with JavaScript enabled) in my app to display a link programmatically. I send the url to it, and it loads. I do the same thing, instead sending it programmatically to a browser on the phone.
These look like the first picture.
The problem is the page displayed in both of these cases is different than if I copy and paste the link (generated in the app from the Log) to the same browser on the device manually, or open it on my desktop browser. These look like second picture.
A sample link is:
http://lyrics.wikia.com/index.php?title=Future:Karate+Chop+%28Remix%29&action=edit
Why could this be?
Sounds like you need to override the shouldOverrideUrlLoading in your WebViewClient, which should be attached to your webview, also in the overriden method it should return false if you want your webview to handle it.
The second thing I would recommend would be to also change the UserAgent that is being attached to your WebVIew as well since you're seeing a difference in Desktop/Mobile version of the website.
You can learn more about tweaking the user agent here:
Want to load desktop version in my webview using uastring
I am trying to add a podcast and a youtube channel to my native Android app, but it seems it would be much easier if I just use HTML and access that media as it is on the web.
Is it possible to have an activity be HTML5 or a basic web view? If so, how can I do that?
Thanks!
Yes this is possible, have a look into WebView
http://developer.android.com/reference/android/webkit/WebView.html
A View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.
You may find some performance/compatability issues but this is the easiest solution and one that I would do as a first step.
First, a disclaimer: i'm completely new to iphone, android or any mobile development. In the other side, i've been developing websites (php, javascript) for long time.
I have a website which is adapted for mobile and works great. But, there are some features i need such as prevent the screen from dimming (my site is designed to be used for many hours without user interaction while being permanently visible or for example being able to send notifications (with sound, etc., to attract user attention)).
This has lead me to consider a webview. From what i've seen, it's about creating a native app which just a webview (browser without toolbars) and using html and javascript to operate. It will use some native functions to perform some native actions (such as the ones i want).
I've searched around and i don't have a specific response to this: can i tell a webview to, permanently load the content from a remote site ? i mean, my site is php based (zend), with many jquery content manipulation. Can i tell him something like LOAD htp://www.mysyite.com and let him do everything else from it ? absolutely no local content applies, everything is remote. The webview would just be an "interface" to the website.
And additional question is: can i use jquery on it ? ajax calls ? geolocation ? i mean, in a browser i can, i just wonder if inside a webview i can.
I've read that phonegap does this. But most of the time, when taking about phonegap and about webview i general, i read people talking about loading locally the page not remotely in a permanent basis.
Finally, yes, i will build a native app in the future. But now, i simply don't have time to learn about android, ios and blackberry at the same time. Thanks a lot for your responses.
For Android only:
Can i tell him something like LOAD htp://www.mysyite.com and let him do everything else from it ? absolutely no local content applies, everything is remote. The webview would just be an "interface" to the website.
Yes, of course you can. Suppose you have a webview in an activity (it's really easy), you would load the web page something like:
WebView myWebView = .... // get a reference from XML or if you just created get its ref
myWebView.loadURL("http://www.mysite.com");
I would start with this API Guide article. Also, taken from WebView JavaDoc:
A WebView has several customization points where you can add your own behavior. These are:
Creating and setting a WebChromeClient subclass. This class is called when something that might impact a browser UI happens, for instance, progress updates and JavaScript alerts are sent here (see Debugging Tasks)
Creating and setting a WebViewClient subclass. It will be called when things happen that impact the rendering of the content, eg, errors or form submissions. You can also intercept URL loading here (via shouldOverrideUrlLoading()).
Modifying the WebSettings, such as enabling JavaScript with setJavaScriptEnabled().
Injecting Java objects into the WebView using the addJavascriptInterface(Object, String) method. This method allows you to inject Java objects into a page's JavaScript context, so that they can be accessed by JavaScript in the page.
Please be also aware that the webview is not that powerful as the phone's browser. Here is a SO thread where a friend posted an interesting question. You might find helpful the answers he got.
I don't quite understand the cordova plugin procedure.
I found out that it works through the Cordova Webview, but I don't know which
functions and classes are necessary.
It would be great if someone had the time to explain it, a sequencediagramm would be the best for understanding.
greetings, Kurt
This may help you to understand more:
Using WebViews
A WebView uses the same rendering and JavaScript engine as the browser, but it runs under the control of your application. The WebView can be full screen or you can mix it with other Views. The content for your WebView can come from anywhere. The WebView can download content from the web, or it can come from local files stored in your assets directory. The content can even be dynamically generated by your application code.
and
Android WebView, Javascript and CSS
I have come across some situations where I had to use a WebView to display some HTML content. Displaying HTML content is pretty straight-forward. But when it comes to controlling the web view, it gets a little complex. Things like showing alerts, manipulating divs and controlling the activity (closing/finishing). This example shows a few techniques that will get you going with Javascript and CSS with WebView.
I am making an app a bit like a dictionary, where a user clicks on a word and get a display of an image and an explanation of that word. I know that WebView allows me to use html formatting but I have read that it takes a lot of memory. Is there any disadvantage to using a WebView in this way or should I use a TextView?
WebView works well on my phone, an HTC Wildfire.
TextView works fine if you only want to display text -- or only very simple formating.
If you want to display something more advanced, WebView will definitely allow you to do more, as it allows one to use Full-HTML.
Of course, this requires more power... but, still, if you are only using one WebView at a time on your screen/activity, it cannot be worse than when using the browser application -- and that one works fine, doesn't it ?