1.Android是什么 手機設備的軟件棧,包括一個完整的操作系統、中間件、關鍵的應用程序,底層是linux內核,安全管理、內存管理、進程管理、電源管理、硬件驅動 2.Dalvik VM 和 JVM 的比較 
3.常見adb指令 platform-tools/adb.exe adb.exe : android debug bridge android調試橋 adb devices:列出所以連接的設備 adb kill-server :殺死adb調試橋 adb start-server :啟動adb調試橋 adb install xxx.apk 如果有多個設備,我們可以指定設備 adb install –s emulator-5554 D:/xxx.apk adb uninstall 包名 : 卸載應用 adb pull 源文件 目標文件 : 導出文件 adb push 源文件 目標文件 : 導入文件 4.Android應用程序架構 
5.程序打包&安裝的過程 
6.電話撥號器 代碼提示鍵:Alt+/ 出現黃色的解決方式: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()) { case R.id.bt_dail: String number = dt_number.getText().toString().trim(); if (TextUtils.isEmpty(number)) { Toast.makeText(PhoneActivity.this, "號碼不能為空!", 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" > <!--決定啟動哪個activity--> <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種寫法 (1).創建一個內部類定義點擊事件 bt_dail.setOnClickListener(new MyListener()); private class MyListener implements OnClickListener (2).采用匿名內部類創建點擊事件 bt_dail.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub } }); (3).讓類實現點擊事件的接口,(常用) public class PhoneActivity extends Activity implements OnClickListener public void onClick(View v) { switch (v.getId()) { case R.id.bt_dail: default: break; } (4).在布局文件中綁定一個點擊(android:onClick="") android:onClick="dail" public void dail(View view) {} 8.短信發送器 <?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="請輸入電話號碼" > <requestFocus /> </EditText> <EditText android:id="@+id/et_content" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="請輸入內容" android:lines="5" /> <Button android:id="@+id/bt_send" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="發送" /> </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, "電話號碼或內容不能為空!", 0).show(); } else { PendingIntent sentIntent = PendingIntent.getBroadcast(SMSActivity.this, 0, new Intent(), 0); SmsManager smsManager = SmsManager.getDefault(); //如果字數超過70,需拆分成多條短信發送 ArrayList<String> contents = smsManager.divideMessage(content); for (String str : contents) { //最后二個參數為短信已發送的廣播意圖,最后一個參數為短信對方已收到短信的廣播意圖 smsManager.sendTextMessage(number, null, str, sentIntent,null); } Toast.makeText(SMSActivity.this, "短信發送完成", Toast.LENGTH_LONG).show(); } } }); } } <uses-permission android:name="android.permission.SEND_SMS"/> 9. Android 中各種布局 <!-- LinearLayout - 線形布局。 orientation - 容器內元素的排列方式。vertical: 子元素們垂直排列;horizontal: 子元素們水平排列 gravity - 內容的排列形式。常用的有 top, bottom, left, right, center 等,詳見文檔 --> <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 - 層疊式布局。以左上角為起點,將 FrameLayout 內的元素一層覆蓋一層地顯示 --> <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 - 表格式布局。 TableRow - 表格內的行,行內每一個元素算作一列 collapseColumns - 設置 TableLayout 內的 TableRow 中需要隱藏的列的列索引,多個用“,”隔開 stretchColumns - 設置 TableLayout 內的 TableRow 中需要拉伸(該列會拉伸到所有可用空間)的列的列索引,多個用“,”隔開 shrinkColumns - 設置 TableLayout 內的 TableRow 中需要收縮(為了使其他列不會被擠到屏幕外,此列會自動收縮)的列的列索引,多個用“,”隔開 --> <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="行1列1" /> <TextView android:layout_width="wrap_content" android:layout_weight="1" android:layout_height="wrap_content" android:text="行1列2" /> <TextView android:layout_width="wrap_content" android:layout_weight="1" android:layout_height="wrap_content" android:text="行1列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="行2列1" /> </TableRow> </TableLayout> <!-- AbsoluteLayout - 絕對定位布局。 layout_x - x 坐標。以左上角為頂點 layout_y - y 坐標。以左上角為頂點 --> <AbsoluteLayout android:layout_height="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 - 相對定位布局。 layout_centerInParent - 將當前元素放置到其容器內的水平方向和垂直方向的中央位置(類似的屬性有 :layout_centerHorizontal, layout_alignParentLeft 等) layout_marginLeft - 設置當前元素相對於其容器的左側邊緣的距離 layout_below - 放置當前元素到指定的元素的下面 layout_alignRight - 當前元素與指定的元素右對齊 --> <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>