I'm working on an HTML5 based Android App, and I don't understand how to get WebView working. I was wondering if anyone could point me to a place where I can download the source code for an example application of this so I can modify it for my app, or at least reference it. It needs JavaScript support, and to open links in WebView, instead of in the Browser application, which I heard happens unless you change a setting. It will access local files only, not from the internet, but might later on interface with database systems, so it needs the Internet permission, but I think I understand how to add that. Thank you!
I will suggest you too have a look on Cordova.
You can find everything to start a hybrid android app.
Related
I am building a Hybrid application for android which has a String value stored in a variable.
I have the application installed in my mobile, and now I need to fetch the String value (from that hybrid app) through a JavaScript call from a browser (web page opened in the same mobile). How can I achieve this?
Forgive for the abstractness in the question, as I am a newbie to both Android and Web app development.
Answering my own question, hoping it might help anyone later.
After so much of online reading, I've found it is not possible to read values embedded within another app. (Except exposing the variable through an external API as Mr. Michal Hainc pointed out rightly in the comment)
I've created a website for a client's salesforce to use in hospitals, where they can't use wifi to access the internet as it can interfere with sensitive medical equipment. The website uses HTML, CSS and Javascript and does not require any form of server to work, which is fine when run locally on a laptop. However, they now want to use iPads and I've been trawling the Net for a simple solution in which I could copy the entire site to an iPad, while maintaining the site's directory structure, and then launch it locally with the browser. Nothing that I've found seems to be able to do this, although it seems such a ridiculously straightforward thing.
The best I've been able to do is to email the zipped site to my iPod, and then use the FileManager app to unzip and run the site in its own browser. It's useable but not great (every time you tap something you get an overlay at the top of the page) and there's no way I can find of adding a shortcut to the desktop - is there a better way of doing this?
You can look into something like React Native which allows you to write javascript HTML applications and deploy them as native iOS and Android applications. It shouldn't require too much work to move it over enough to just compile it and run it as you do currently.
https://facebook.github.io/react-native/
Cordova to package it in to an app https://cordova.apache.org/
I have a simple script from AccuWeather to display a weather button on my website:
I love the simple way this button displays. It's perfect for what I want.
However, the button generated is in Adobe Flash format (swf) and doesn't display on most mobile devices since iOS and Windows Phone have no support and Flash Player for Android is no longer available for download from the Google Play app store.
I thought I found a solution in an Open Source project called Smokescreen that has its development area at Github.
I don't need this to reproduce flash movies. All I need is a simple javascript-based conversion of the flash button to a flat image that can be displayed in any browser that can execute javascript, which includes mobile devices.
But the documentation and description of how to use Smokescreen at their GitHub site is minimal at best, and I'm not a javascript expert and cannot get it working.
The call I am making that obtains the Flash image from AccuWeather is:
<script src='http://netweather.accuweather.com/adcbin/netweather_v2/netweatherV2ex.asp
?partner=netweather&tStyle=whteYell&logo=0&zipcode=NAM|CA|MB|WINNIPEG|
&lang=eng&size=7&theme=blue&metric=1&target=_self'>
</script>
Can anyone tell me what the javascript would be to use Smokescreen to display the flash image produced by the above code as an image.
If Smokescreen can't do it, is there any other method that can do this live on a webpage?
Just tested smokescreen with the SWF of the page you posted, and it doesn't work, you will need to parse the SWF at server side if you still want to use that site.
I opened the dev console and tracked down the SWF from the iframe
copied the file into my computer, then
cloned the github repo and
edited the player.html (from the github repo), line 13 to point to the file I downloaded.
This is the SWF I downloaded: http://netwx.accuweather.com/netWx-V212.swf?zipcode=46958
Edit: this is the error message I got from the dev console:
TypeError: this.defineEditText is not a function [loader.js:136](https://github.com/cesmoak/smokescreen/blob/master/src/player/loader.js#L136)
My system asks for permission to allow the SWF to connect to netwx.accuweather.com.
A quick search on github reveals some nice pure javascript alternatives.
https://github.com/search?l=JavaScript&q=weather&ref=searchresults&type=Repositories
I think this one looks the most promising: http://simpleweatherjs.com/
This simpleweatherjs demo shows a nice icon as well: http://codepen.io/fleeting/pen/wHism
unfortunately there is no way your javascript can handle swf, espacially on mobile devices like whith ios or windows phone since the javascript is running on your device itself.
all you could try is to use swfobject which is described as a workaround for javascript
here is the documentation of swfobject
Have you considered using a headless browser like phantomjs? You could use something like Selenium instead for out-of-the-box plugin support, but there are headless options for Flash.
The beauty of such software is that it can automate any user task (that's why it's used for testing). Like logging onto a site and performing a search that would normally not be available externally because of antiforgery tokens. Or checking if a product's price has changed by seeing if its DOM element value's has changed. Or accessing your online banking to see if your balance is a prime number and rendering your credit card bill in fractal form.
I mean, if you want to go this far for a weather widget, you probably have power user needs :)
...also Accuweather seems to do a fairly similar mobile-friendly version. And if it's not 100% the same, you could always ask.
Edit: check their T&C, the mobile-friendly snippet might actually be the only option for legal reasons.
I'm trying to develop a small Windows 8 App as a test for a larger project that I'll be working on.
I'm using VS 2012, HTML, CSS, and Javascript. I've been able to create, build and deploy the app with out a problem, however I notice that if I put my tablet into airplane mode (i.e. take it offline) and then try to open the app, I just get a black screen.
Is there a "best practice" for handling offline scenarios?
I am familiar with using manifest for mobile web apps, but this doesn't seem matter here.
Use applicationData. http://msdn.microsoft.com/en-us/library/windows/apps/hh465118.aspxSource: http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/a5f0477d-c665-477e-b118-77446b7029ce
Need to use NetworkStatusChange event and take require action. this quickstart at msdn also documents the best practices.
You can try out some application from Microsoft like Store, news, music to give idea for offline behavior of your app.
I am blackberry developer and I don't have any experience in Android programming.
I am trying to create an android application which will have webview/embedded browser. I will load some web page with some javascripts in embedded browser. There will be some buttons on the page which will call javascript functions. Some of these functions require access to native APIs (eg Camera API). Is it possible to call native api's from javascript functions or access to native code of the app ?
Right now this is possible in blackberry platform using Javascript extension. I'm expecting something similar in Android.
Thank you.
Anyone who is looking for the answer, I've found solution based on #dtanders answer.
Check this out:
http://developer.android.com/guide/webapps/webview.html#BindingJavaScript
Use http://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface(java.lang.Object, java.lang.String) to expose Java interfaces to the JavaScript running in the WebView
Well, if you specifically want the Camera API, it can be done. From your JS code, you can call a piece of Java code which will in turn trigger the Camera App, take a picture, return the image's URL, which your Java code can forward it to a JS method.
See:
http://developer.android.com/guide/webapps/index.html
http://developer.android.com/guide/webapps/webview.html
Its a complete shot in the dark on my part but these might have some useful information for you.
Webview not responding to touch events
Does Android support click events in its WebView?
Also don't forget that WebViews have javascript disabled by default you'll need to explicitly set it to true in order to make it work.