System player for Java and JS Mutual tune

Source: Internet
Author: User

<?XML version= "1.0" encoding= "Utf-8"?><Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Tools:context= "Com.example.androidandh5.JsCallJavaCallPhoneActivity">    <WebViewAndroid:id= "@+id/webview"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"/></Relativelayout>



Public classJscalljavavideoactivityextendsActivity {PrivateWebView WebView; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_js_call_java_video); WebView=(WebView) Findviewbyid (R.id.webview); WebSettings websettings=webview.getsettings (); //set support JavaScript footstep languageWebsettings.setjavascriptenabled (true); //Double-click Support-provided the page is supported for display//Websettings.setusewideviewport (TRUE); //Support for zoom buttons-provided the page is supported for displayWebsettings.setbuiltinzoomcontrols (true); //set client-do not jump to the default browserWebview.setwebviewclient (Newwebviewclient ()); //Set Support JS call JavaWebview.addjavascriptinterface (NewAndroidandjsinterface (), "Android"); //Load network resources//Webview.loadurl ("http://atguigu.com/teacher.shtml");Webview.loadurl ("file:///android_asset/RealNetJSCallJavaActivity.htm");//Webview.loadurl ("http://10.0.2.2: 8080/assets/realnetjscalljavaactivity.htm "); } classAndroidandjsinterface {/*** This method will be called by JS *@paramID *@paramVideourl *@paramTile*/@JavascriptInterface Public voidPlayVideo (intid,string videourl,string Tile) { //Tune up all players in the systemIntent Intent =NewIntent (); Intent.setdataandtype (Uri.parse (videourl),"video/*"); StartActivity (Intent); } }}

System player for Java and JS Mutual tune

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.