Android PhoneGap uses Activity to achieve cordovainterface

Source: Internet
Author: User

1. Modify Main.xml

1 <?xml version= "1.0" encoding= "Utf-8"?>   2 <linearlayout xmlns:android= "/http Schemas.android.com/apk/res/android "   3     android:layout_width=" match_parent "   4     android:layout_height= "Match_parent"  5     android:orientation= "vertical" >   6     <org.apache.cordova.CordovaWebView   7         android:id= "@+id/cordovawebview1"   8         android:layout_width= "Match_ Parent "   9         android:layout_height=" match_parent "/>   </linearlayout >  

2. Modify activity to implement Cordovainterface interface members.

1 Public class Demoactivity extends Activity implements Cordovainterface {2           3Private final Executorservice ThreadPool =Executors.newcachedthreadpool (); 4 private Cordovawebview Cordovawebview; 5 @Override6PublicvoidonCreate (Bundle savedinstancestate) {7 super.oncreate (savedinstancestate); 8                  9 Setcontentview (R.layout.main); Ten                   OneCordovawebview =(Cordovawebview) Findviewbyid (R.ID.CORDOVAWEBVIEW1);  A                   -Cordovawebview.loadurl ("file:///android_asset/www/index.html");  -         }   the            - @Override -PublicvoidOnDestroy () { - Super.ondestroy ();  +                 if(Cordovawebview! =NULL) {   - Cordovawebview.handledestroy ();  +                 }   A         }   at            - @Override -Publicvoidstartactivityforresult (Cordovaplugin command, Intent Intent, -                         intRequestcode) {   -                 //TODO auto-generated Method Stub -         }   in @Override -Publicvoidsetactivityresultcallback (Cordovaplugin plugin) { to                 //TODO auto-generated Method Stub +         }   - @Override the Public Activity getactivity () { *                 //TODO auto-generated Method Stub $                 return  This; Panax Notoginseng         }   - @Override the Public Object onMessage (String ID, object data) { +                 //TODO auto-generated Method Stub A                 return NULL;  the         }   + @Override - Public Executorservice Getthreadpool () { $                 //TODO auto-generated Method Stub $                 returnThreadPool;  -         }   -}

Note: Program exit prompt Logoff WebView

3. You can modify android:theme:AppTheme in the application node in the manifest file, do not display the application title bar

1 <style name= "Apptheme" parent= "Appbasetheme" >  2     <item name= "Android: Windownotitle ">true</item>  3 </style>  

Android PhoneGap uses Activity to achieve cordovainterface

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.