- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML5
Use Mediaplayer of Android for playing audio. You need to call function of Android from JavaScript that you have written in HTML file.
WebView wv = (WebView) findViewById(R.id.webview); wv.addJavascriptInterface(new WebAppInterface(this), "Android"); public class WebAppInterface { Context mContext; WebAppInterface(Context c) { mContext = c; } @JavascriptInterface public void showToast(String toast) { Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show(); } }
The following is my JavaScript:
<input type = "button" value = "Demo" onClick = "showAndroidToast('Hello Android!')" /> <script> function showAndroidToast(toast) { Android.showToast(toast); } </script>
- Related Articles
- Working with tag in HTML5
- Playing MP4 video in WebView using HTML5 in Android
- canvas.style.display = “block” not working in HTML5
- HTML5 tag on Android for PhoneGap application
- HTML5 tag
- Why formaction attribute is not working outside of tag?
- The:last-child selector not working as expected in HTML5
- HTML5 video not working with jquery bxSlider plugin on iPad
- Why to use canvas tag in HTML5?
- How to add webview focus in android?
- How to clear webview history in android?
- How to save password in android webview?
- How to show pdf in android webview?
- HTML5 SVG css3 transition on fill not working when there is external link
- HTML5 Server-Sent Events working

Advertisements