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