Learning Goal: webapp--to pack HTML5 apps into Android phones.
Features: Low code volume! Simple idea! -The process is a bit messy and error prone!
Interview questions: What are the differences between process-oriented (function) and object-oriented (objects)? Process-oriented language: C, C + +, JavaScript, php--bottom software, such as three basic software Object-oriented language: C + +, JavaScript, PHP, Java, c#--High-level application software |
Hybrid App = Nativeapp + WebApp
1. Comparison of native apps and WebApp
Native (Native) app means:
IOS (LINUX-C): Objective-c, Swift
Android (LINUX-C): Java
WebApp refers to:
A mobile web app written using HTML5. A webapp can be run on the PC, Android, iOS and other platforms almost without modification.
Advantage: A set of code runs everywhere.
Disadvantage: Some of the underlying features are missing and run less quickly than native apps.
(1) Guaranteed to see and open my phone in "My Computer"
(2) android system = + settings + Developer options = + Enable USB debugging
You can install your own mobile app to the Android system directly.
Construction of 2.Android development environment
(1) Download and install the Java program's operating Environment--JDK (Javadevelopmentkit)
BAIDU:JDK Installation
Ensure that input java.exe on the command line can be run
(2) Download and unzip the Android app development Environment--adt (ANDROIDDEVELOPERTOOLS)
(3) Start Adt:eclipse/eclipse.exe
(4) Create a virtual Android device--android VM Manager
Note: There are real Android phones that can omit this step in
Eclipse->window->openperspective->ddms
You can view your phone in the interface
(5) Create Android apps, select Custom icons, customize the contents of Windows, install real phone or virtual phone.
Tip: If ADT is unable to find the real phone, you can run the project and build the Android application installer in the Bin directory: xxx.apk can directly copy this file to the SD card of the phone and install the APK file directly using the phone.
Directory structure for 3.Android applications
How to set up a full-screen display window:
To modify a project manifest file Androidmanifest.xml:
<application android:theme= "@android: Style/theme.notitlebar.fullscreen" >
4. Create a Hybridapp
Hybrid app: Icons, like native apps, that show a native app window (called activity), with only one component-a browser kernel (without the address bar)-that restricts the browser's kernel to displaying only specific pages.
Create WebView component--for displaying Web page content (that is, the core of the browser)
WebView WV = new WebView (this); Creating a browser Core object
This.setcontentview (WV); Add the WebView component to the form
1) use WebView to load the packaged Android local Web page in the apk file:
All Html/css/js must be saved under the assets directory of the Android project
WebView WV = new WebView (this);
This.setcontentview (WV);
Wv.getSettings.setJavaScriptEnabled (TRUE); Enable JS Support
Wv.loadurl ("file:///android_asset/xx.html"); Loading the local HTML file
2) to load a Web page on a remote Web server by using WebView:
In addition to the above steps, you will need to ask the user for network usage rights:
In Androidmanifest.xml:
<uses-permission android:name= "Android.permission.INTERNET" >
In Mainactivity.java:
Wv.loadurl ("http://tmooc.cn"); HTML file to load the Internet
webapp-Build Android Development environment