Android first day

Source: Internet
Author: User
<span id="Label3"></p><pre><pre><br></pre></pre><p style="text-indent:2em;text-align:left;"><br style="font-family:Arial;font-size:14px;line-height:22px;white-space:normal;"><span style="font-family:Arial;font-size:14px;line-height:22px;"><span style="font-family:Arial;font-size:14px;line-height:22px;">A. Four-tier architecture of the Android system</span></span><br style="font-family:Arial;font-size:14px;line-height:22px;white-space:normal;"><span style="font-family:Arial;font-size:14px;line-height:22px;">the <span style="font-family:Arial;font-size:14px;line-height:22px;">First Layer: applications: This is the application of the system on the mobile phone or the third party application</span></span><br style="font-family:Arial;font-size:14px;line-height:22px;white-space:normal;"><span style="font-family:Arial;font-size:14px;line-height:22px;"><span style="font-family:Arial;font-size:14px;line-height:22px;">Second Layer: application Framework: This is the java-related API section</span></span><br style="font-family:Arial;font-size:14px;line-height:22px;white-space:normal;"><span style="font-family:Arial;font-size:14px;line-height:22px;"><span style="font-family:Arial;font-size:14px;line-height:22px;">layer three: includes two parallel parts</span></span><br style="font-family:Arial;font-size:14px;line-height:22px;white-space:normal;"><span style="font-family:Arial;font-size:14px;line-height:22px;"><span style="font-family:Arial;font-size:14px;line-height:22px;">1. Class Library: Liberties</span></span><br style="font-family:Arial;font-size:14px;line-height:22px;white-space:normal;"><span style="font-family:Arial;font-size:14px;line-height:22px;"><span style="font-family:Arial;font-size:14px;line-height:22px;">2.Android RUNTIME:DVM (android virtual machine)</span></span><br style="font-family:Arial;font-size:14px;line-height:22px;white-space:normal;"><span style="font-family:Arial;font-size:14px;line-height:22px;"><span style="font-family:Arial;font-size:14px;line-height:22px;">the bottom: Linux kernel</span></span><br style="font-family:Arial;font-size:14px;line-height:22px;white-space:normal;"><span style="font-family:Arial;font-size:14px;line-height:22px;"><span style="font-family:Arial;font-size:14px;line-height:22px;">two. The difference between a DVM and a JVM</span></span><br style="font-family:Arial;font-size:14px;line-height:22px;white-space:normal;"><span style="font-family:Arial;font-size:14px;line-height:22px;"><span style="font-family:Arial;font-size:14px;line-height:22px;">dvm:.java-->.class-->.dex-->.apk</span></span><br style="font-family:Arial;font-size:14px;line-height:22px;white-space:normal;"><span style="font-family:Arial;font-size:14px;line-height:22px;"><span style="font-family:Arial;font-size:14px;line-height:22px;">JVM:. Java-->.class-->.jar</span></span><br style="font-family:Arial;font-size:14px;line-height:22px;white-space:normal;"><span style="font-family:Arial;font-size:14px;line-height:22px;"><span style="font-family:Arial;font-size:14px;line-height:22px;">Three. Android New Virtual Machine:</span></span><br style="font-family:Arial;font-size:14px;line-height:22px;white-space:normal;"><span style="font-family:Arial;font-size:14px;line-height:22px;"><span style="font-family:Arial;font-size:14px;line-height:22px;">1.ART: The first time the application is installed, bytecode is compiled into a machine code to make it a true native Application.</span></span></p><p style="text-indent:2em;text-align:left;"><span style="font-family:Arial;font-size:14px;line-height:22px;"><span style="font-family:Arial;font-size:14px;line-height:22px;">When you start again, the execution speed Increases. </span></span><br style="font-family:Arial;font-size:14px;line-height:22px;white-space:normal;"><span style="font-family:Arial;font-size:14px;line-height:22px;"><span style="font-family:Arial;font-size:14px;line-height:22px;">2.DALVK (old): Each time the application is run, it will be recompiled into bytecode, the execution speed is SLOW. </span></span><br style="font-family:Arial;font-size:14px;line-height:22px;white-space:normal;"><span style="font-family:Arial;font-size:14px;line-height:22px;"><span style="font-family:Arial;font-size:14px;line-height:22px;">Four. Android Project directory structure</span></span><br style="font-family:Arial;font-size:14px;line-height:22px;white-space:normal;"><span style="font-family:Arial;font-size:14px;line-height:22px;"><span style="font-family:Arial;font-size:14px;line-height:22px;">* Activity: The interface displayed when the app is opened</span></span></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* Src: Project Code</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* R.java: resource ID for all resource files in the project</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* Android.jar:Android jar package, Import this package to use Android API</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* Libs: Import Third party jar package</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* Assets: Storage resource files, such as mp3, video files, read through IO stream</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* Bin: store compiled and packaged files</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* Res: Storage Resource file, All resource files stored in this folder will generate resource ID</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* Drawable: Storage of picture resources</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* Layout: Store the layouts file, assign the layout file to the activity through the resource id,</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">The interface will show the layout of the layout file definition</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* Menu: defines the style <span style="text-indent:2em;"></span> of the menu</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;"># # #Android的配置文件 (manifest File)</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* Specify the package name of the app</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">Package= "com.itheima.helloworld"</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* Data/data/com.itheima.helloworld (the Package name specified in the code above)</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* The files generated by the app will be stored in this path</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* All four components of Android need to be configured in the manifest file before use</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* <Application/> configuration is effective for the entire application</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">* <activity/> configuration is valid for this activity</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">To apply the packaging process:</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">. java-->.dex, .apk-->sign--> Installation<br></p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">ADB: Android Debug Bridge to build bridges between Eclipse and Android devices<br></p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">Some of the most commonly used adb commands:<br></p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;"></p></p><p><p>* ADB start-server: start adb process</p></p><p><p>* ADB kill-server: kill ADB process</p></p><p><p>* adb devices: View the devices currently connected to the development environment, This command can also start the ADB process</p></p><p><p>* adb install xxx.apk: installing APK to Simulator</p></p><p><p>* ADB Uninstall Package name: Remove the app from the emulator</p></p><p><p>* ADB shell: Enter the Linux command line</p></p><p><p>* Ps: View Running Process</p></p><p><p>* Ls: View the file structure under the current directory</p></p><p><p>* Netstat-ano: View the process that occupies the port</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">Five. Simple Application<br></p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">1. Telephone Dialer:<br></p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">Some of the important code is edited in mainactivity.java, and note to set permissions in the manifest allows:</p></p><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;"><uses-permission android:name= "android.permission.CALL_PHONE"/></p></p><pre class="brush:java;toolbar:false;">               protected void  oncreate (bundle savedinstancestate)  {                     super.oncreate (savedInstanceState);                      setcontentview (r.layout.activity_main);           &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;//LOG.D ("the first one",  " Heheheheheheh ");                     button bt= (Button) Findviewbyid (r.id.button1);                      Bt.setonclicklistener (new myclick ()); &NBSP;&NBSP;&NBsp;             }                                                                  class MyClick implements OnClickListener{                           @Override             public void  OnClick (view v)  {            //  todo auto-generated method stub             edittext et= (EditText) Findviewbyid (r.id.edittext1);             String val=et.gettext (). toString ();             intent intent=new intent ();             intent.setaction (intent.action_call);             intent.setdata (uri.parse ("tel:" +val);             startactivity (intent);            }                                  }</pre><p style="text-indent:2em;text-align:left;"><p style="text-indent:2em;text-align:left;">2. Click on the event in several<span style="text-indent:2em;"> </span> <span style="text-indent:2em;"></span> ways:</p></p><p><p># # #第一种</p></p><p><p>* Define a MyListener implementation Onclicklistener interface</p></p><pre class="brush:java;toolbar:false"><pre class="brush:java;toolbar:false">Button BT1 = (button) Findviewbyid (r.id.bt1); Bt1.setonclicklistener (new MyListener ());</pre></pre><p><p># # #第二种</p></p><p><p>* Define an anonymous inner class implementation Onclicklistener interface</p></p><pre class="brush:java;toolbar:false"><pre class="brush:java;toolbar:false">             button bt2 =  (Button)  findviewbyid (r.id.bt2);                     bt2.setonclicklistener (new  Onclicklistener ()  {                          @Override              public void onclick (view v)  {             system.out.println ("second type");                         }             }); </pre></pre><p><p># # #第三种</p></p><p><p>* Let current activity implement Onclicklistener interface</p></p><pre class="brush:java;toolbar:false"><pre class="brush:java;toolbar:false">Button BT3 = (button) Findviewbyid (r.id.bt3); Bt3.setonclicklistener (this);</pre></pre><p><p># # #第四种</p></p><p><p>* Set the OnClick property to the button node,</p></p><p><p>android:onclick= "click"</p></p><p><p>* Then define a method with the same name as the property value in activity</p></p><pre class="brush:java;toolbar:false"><pre class="brush:java;toolbar:false">public void Click (View v) {System.out.println ("fourth type"); }</pre></pre><p><p>3. SMS Transmitter<br></p></p><p><p>This simple example uses the fourth mode of the click event, and does not forget to add the Permission:</p></p><p><p><uses-permission android:name= "android.permission.SEND_SMS"/> Specific code is as Follows:<br></p></p><p><p></p></p><pre class="brush:java;toolbar:false">            public void send (View v ) {                     //get the number and content entered by the user             edittext  et_phone =  (EditText)  findviewbyid (r.id.et_phone);             EditText et_content =  (EditText)  findviewbyid (r.id.et_ content);                         string phone = et_phone.gettext (). toString ();             string content = et_ Content.gettext (). toString ();                         //1. Get SMS Manager              smsmanager sm = smsmanager.getdefault ();                         //2. Cutting SMS , divide long text messages into a few short messages             ArrayList<String>  smss = sm.dividemessage (content);           The               //3.for loop sends out all the text messages in the Collection.             for  (string string :  smss)  {                     sm.sendtextmessage (phone, null, string, null, null);         }            } </pre><p><p><br></p></p><p><p>Android first day</p></p></span>

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.