Non-nonsense Android's common ADB instructions, Phone Dialer, 4 ways to click events, SMS transmitters, various layouts in Android (1)

Source: Internet
Author: User

1. What Android is a software stack for mobile devices,includes a complete operating system, middleware, key applications, the underlying Linux kernel, security management, memory management, process management, power management, hardware drivers2. Dalvik VM and JVM comparisons
3 . Common adb directives platform-tools/adb.exeadb.exe:android Debug Bridge Android Debug Bridges adb devices: List so connected devices adb Kill-server: Kill adb Debug bridge adb start-server: start adb debug bridge adb install xxx.apk If there are multiple devices, we can specify the device adb install–s emulator-5554d:/xxx.apkadb Uninstall Package Name: Uninstall application adb pull source file destination file: Export file adb push source file Destination file: Import file4. Android Application Architecture
5. Procedures for Packaging & installation
6 . Phone Dialer code hint key: alt+/Yellow solution: Ctrl +1<relativelayout xmlns: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=". Phoneactivity "> <edittext android:id= "@+id/et_number"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:inputtype= "Phone"/> <button android:id= "@+id/bt_dail"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_alignparentright= "true"Android:layout_below= "@+id/et_number"Android:text= "@string/dail"/></relativelayout>package Com.example.demo1;Import android.app.Activity;Import Android.content.Intent;Import Android.net.Uri;Import Android.os.Bundle;Import Android.text.TextUtils;Import Android.view.View;Import Android.view.View.OnClickListener;Import Android.widget.Button;Import Android.widget.EditText;Import Android.widget.Toast;Public class Phoneactivity extends Activity implements Onclicklistener {private EditText dt_number= NULL;@Override protected void onCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);Setcontentview (R.layout.activity_phone);Button Bt_dail = (button) This.findviewbyid (r.id.bt_dail);Dt_number = (EditText) This.findviewbyid (R.id.et_number);Bt_dail.setonclicklistener (This);} public void OnClick (View v) {switch (V.getid ()) {r.id.bt_dail:st Ring Number= Dt_number.gettext (). toString (). Trim ();if (textutils.isempty (number)) {Toast.maketext (Phoneactivity.this, "The number cannot be empty!" ",toast.length_short). Show ();Return;} Intent Intent= new Intent ();Intent.setaction (Intent.action_call);Intent.setdata (Uri.parse ("Tel:" + number);StartActivity (Intent);Break;Default:break;}}}<activity android:name= "Com.example.demo1.PhoneActivity"Android:label= "@string/title_activity_phone"> <!--decide which activity--> to start <intent-filter> <action android:name= "Android.intent.action.MAIN"/> <category android:name= "Android.intent.category.LAUNCHER"/> </intent-filter></activity> <uses-permission android:name= "Android.permission.CALL_PHONE"/>7 4 ways to click events (1). Create an internal class definition click event Bt_dail.setonclicklistener (New MyListener ());Private class MyListener implements Onclicklistener (2). Create a Click event with an anonymous inner class Bt_dail.setonclicklistener (new Onclicklistener () {@Override public V OID OnClick (View v) {//TODO auto-generated Method stub}});(3). Let the class implement the Click event Interface,(common) public class Phoneactivity extends Activity implements Onclicklistenerpublic void OnClick (View v) {switch (V.getid ()) {Case R.id.bt_dail:default:break; }(4). Bind a click in the layout file (android:onclick= "") Android:onclick= "Dail"Public void Dail (view view) {}8 . SMS Transmitter <?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"android:orientation= "Vertical"> <edittext android:id= "@+id/et_number"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:hint= "Please enter phone number"> <requestfocus/> </EditText> <edittext android:id= "@+id/et_content"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:hint= "Please enter content"Android:lines= "5"/> <button android:id= "@+id/bt_send"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:text= "Send"/></linearlayout>package Com.example.demo1;Import Java.util.ArrayList;Import android.app.Activity;Import Android.app.PendingIntent;Import Android.content.Intent;Import Android.os.Bundle;Import Android.telephony.SmsManager;Import Android.text.TextUtils;Import Android.view.View;Import Android.view.View.OnClickListener;Import Android.widget.Button;Import Android.widget.EditText;Import Android.widget.Toast;Public class Smsactivity extends Activity {private EditText medittextnumber= NULL;Private EditText medittextcontent = null;@Override protected void onCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);Setcontentview (r.layout.activity_sms);Button Mbuttonsend = (button) This.findviewbyid (r.id.bt_send);This.medittextnumber = (EditText) This.findviewbyid (R.id.et_number);This.medittextcontent = (EditText) This.findviewbyid (r.id.et_content);Mbuttonsend.setonclicklistener (New Onclicklistener () {public void OnClick (View v) { String Number= Medittextnumber.gettext (). toString (). Trim ();String content = Medittextcontent.gettext (). toString (). Trim ();if (textutils.isempty (number) | | Textutils.isempty (content)) {Toast.maketext (Smsactivity.this, "phone number or content cannot be empty!" ", 0). Show ();} else {pendingintent sentintent= Pendingintent.getbroadcast (smsactivity.this, 0, New Intent (), 0);Smsmanager Smsmanager = Smsmanager.getdefault ();//If the number of words exceeds,need to split into multiple SMS send arraylist<string> contents= Smsmanager.dividemessage (content);for (String str:contents) {//last two parameters for the broadcast intent of the SMS sent,the last parameter is the SMS message that the caller has received the broadcast intent Smsmanager.sendtextmessage ( number, NULL, str, sentintent,null);} toast.maketext (Smsactivity.this, "SMS Send Complete", Toast.length_long). Show (); } } });}}<uses-permission Android:name= "Android.permission.SEND_SMS"/>9. Various layouts <!--linearlayout in Android-linear layout. Orientation-how the elements in the container are arranged. Vertical: The child elements are arranged vertically; horizontal: The child elements are arranged horizontally gravity-the arrangement of the contents. The most commonly used are top, bottom, left, right,Center, see document--><linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"android:gravity= "Right"android:orientation= "Vertical"> <!--framelayout-cascading layouts. The top left corner is the starting point, and the elements inside the framelayout are covered one layer at a level-<framelayout android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"> <textview android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Framelayout"> </TextView> <textview android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Frame Layout"> </TextView> </FrameLayout> <textview android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content" android:text= "@string/hello_world"/> <!--tablelayout-tabular layout. TableRow-rows within a table, each element in the row counts as a column collapsecolumns-sets the column index of the column that needs to be hidden in the TableRow in Tablelayout, with multiple ",Stretchcolumns-Sets the column index of the column in the TableRow in the tablelayout that needs to be stretched (the column is stretched to all available space), with multiple ",Shrinkcolumns-Sets the column index of the column in the TableRow in the tablelayout that needs to be shrunk (in order for the other columns to not be squeezed out of the screen, this column automatically shrinks), and multiple,"separated-<tablelayout android:id= "@+id/tablelayout01"Android:layout_width= "Fill_parent" android:layout_height= "Wrap_content"Android:collapsecolumns= "1"> <tablerow android:id= "@+id/tablerow01" android:layout_width= "Fill_parent"Android:layout_height= "Wrap_content"> <textview android:layout_width= "Wrap_content"Android:layout_weight= "1" android:layout_height= "Wrap_content"Android:text= "Row 1 column 1"/> <textview android:layout_width= "Wrap_content"Android:layout_weight= "1" android:layout_height= "Wrap_content"Android:text= "Row 1 column 2"/> <textview android:layout_width= "Wrap_content"Android:layout_weight= "1" android:layout_height= "Wrap_content"Android:text= "Row 1 column 3"/> </TableRow> <tablerow android:id= "@+id/tablerow01" android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"> <textview android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content" android:text= "Row 2 column 1"/> </TableRow> </TableLayout> <!--absolutelayout-absolute positioning layout. Layout_x-x coordinates. The top left corner is the vertex layout_y-y coordinate. Vertex-to-<absolutelayout android:layout_height in the upper-left corner= "Wrap_content"Android:layout_width= "Fill_parent"> <textview android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content" android:text= "Absolutelayout"android:layout_x= "100px"android:layout_y= "100px"/> </AbsoluteLayout> <!--relativelayout-relative positioning layout. Layout_centerinparent-places the current element in the horizontal and vertical directions within its container (similar properties are: Layout_centerhorizontal,Layout_alignparentleft, etc.) Layout_marginleft-sets the distance of the current element relative to the left edge of its container layout_below-place the current element below the specified element Layout_alignright-The current element is right-aligned with the specified element-<relativelayout android:id= "@+id/relativelayout01"Android:layout_width= "Fill_parent" android:layout_height= "Fill_parent"> <textview android:layout_width= "Wrap_content" android:id= "@+id/abc"Android:layout_height= "Wrap_content" android:text= "Centerinparent=true"android:layout_centerinparent= "true"/> <textview android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content" android:text= "MARGINLEFT=20DP"Android:layout_marginleft= "20DP"/> <textview android:layout_width= "Wrap_content"Android:layout_height= "wrap_content" android:text= "xxx"Android:layout_below= "@id/abc" android:layout_alignright= "@id/abc"/> </RelativeLayout></LinearLayout>

Non-nonsense Android's common ADB instructions, Phone Dialer, 4 ways to click events, SMS transmitters, various layouts in Android (1)

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.