3G hsdpa 7.2M
4G 35Mbps
ophone 基于android改版的操作系统
3G的基带带宽
联通6M 6M/100 600K
移动 3.1M
中国电信 固定网络非常多
3G -> wifi
wap 2.5G 逐步被淘汰
net 互联网
3gnet
android : 操作系统 + 部分应用层软件的集合.
免费 开源.
移动 ophone android
米miui android
cymod
iptv
机顶盒 -> android
2.1 以上的版本 87%
sip通话的支持 : session setup protocol.
会话建立的协议.
ip通话 ip视频协议栈的支持
3.0 3.1 针对平板设计
2.2 2.3 进行开发
2.2 版本
2.3 版本 2.3模拟器
一年android 8K
1.5W
物流网
乐os
android 运行时
dalvik 虚拟机 跟 普通java虚拟机不一样
sun java虚拟机
普通java 虚拟机
.java->.class->解释执行
dalvik ->.class ->.dex
public static final String s="nihao":;
jdk 1.5 以上版本
如果使用eclipse3.7 版本 jdk> 1.6
ADT android development tools
android 开发工具
http://dl-ssl.google.com/android/repository/repository-5.xml
android-2.3.1_r02-linux.zip
http://dl-ssl.google.com/android/repository/android-2.3.1_r02-linux.zip
usb 禁用.
搭建android开发
android 2.2 是google api的子集
如果使用 google 地图 google 纵横
google api level 8
VGA 640*480 像素
hvga half vga 480*320
qvga 1/4 vga 320*240
WVGA 800* 480
FWVGA 854 * 480
luncher 桌面
ddms dalvik debug manager system
dalvik 虚拟器调试系统
sysout();
android 手机 小电脑 可以上网 data
可以打电话的小电脑 可以打电话 voice
模拟器 和 虚拟机的区别是什么 ?
java 虚拟机
dalvik 虚拟机
软件模拟硬件 内存 cpu 显示器
android 很多版本
1.5~4.0
对应数字
1.5 -api 3
1.6 4
2.1 7
2.2 8
4.0 14
4.0.3 15
adb.exe android debug bridge android的调试桥
socket tcp
adb 的文件操作
把一个文件拷贝到手机内存
adb push [源文件] [目标文件]
adb push haha1.txt /mnt/sdcard/haha1.txt
adb pull [源文件] [目标文件]
[2012-03-09 10:33:00 - ddms]transfer error: Invalid argument
[2012-03-09 10:49:49 - DeviceMonitor]Adb connection Error:远程主机强迫关闭了一个现有的连接。
[2012-03-09 10:49:50 - DeviceMonitor]Connection attempts: 1
[2012-03-09 10:49:52 - DeviceMonitor]Connection attempts: 2
[2012-03-09 10:49:54 - DeviceMonitor]Connection attempts: 3
[2012-03-09 10:49:56 - DeviceMonitor]Connection attempts: 4
[2012-03-09 10:49:58 - DeviceMonitor]Connection attempts: 5
[2012-03-09 10:49:59 - DeviceMonitor]Connection attempts: 6
[2012-03-09 10:50:01 - DeviceMonitor]Connection attempts: 7
[2012-03-09 10:50:03 - DeviceMonitor]Connection attempts: 8
[2012-03-09 10:50:05 - DeviceMonitor]Connection attempts: 9
adb 连接的调试桥的socket出现了错误
1. adb kill-server
2. adb start-server
把电脑上的某个应用装(. apk)到模拟器或者手机里面
adb install demo.apk
Failure [INSTALL_FAILED_ALREADY_EXISTS]
卸载一个手机上的程序
adb uninstall [包名]
豌豆夹 91手机助手 qq手机管家 system32 adb.exe
莫名其妙问题 adb 版本不兼容
adb version 查看adb的版本
adb devices 查看当前所有连接上来的设备信息
adb shell 来到模拟器或者是真机的控制台
ls 查看目录信息
ps 查看当前运行进程信息
kill pid 杀死进程
ctrl+F11 横竖屏切换
[2012-03-09 11:16:56 - HelloWorld] ------------------------------
[2012-03-09 11:16:56 - HelloWorld] Android Launch!
[2012-03-09 11:16:56 - HelloWorld] adb is running normally.
[2012-03-09 11:16:56 - HelloWorld] Performing cn.itcast.helloworld.DemoActivity activity launch
[2012-03-09 11:16:56 - HelloWorld] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'iphone'
[2012-03-09 11:16:56 - HelloWorld] Uploading HelloWorld.apk onto device 'emulator-5554'
[2012-03-09 11:16:56 - HelloWorld] Installing HelloWorld.apk...
[2012-03-09 11:17:00 - HelloWorld] Success!
[2012-03-09 11:17:00 - HelloWorld] Starting activity cn.itcast.helloworld.DemoActivity on device emulator-5554
[2012-03-09 11:17:02 - HelloWorld] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=cn.itcast.helloworld/.DemoActivity }
project.properties 指定开发使用的android.jar的版本
default.properties adt 和sdk 的版本过低
proguard.cfg 程序发布时候的混淆 防止别人反编译
AndroidManifest.xml 非常重要 系统的清单文件
相当于 windows操作系统的注册表
<uses-sdk android:minSdkVersion="9" /> android2.3 一下的版本不可以安装这个应用程序
[2012-03-09 11:25:32 - HelloWorld] ERROR: Application requires API version 9. Device API version is 8 (Android 2.2).
[2012-03-09 11:25:32 - HelloWorld] Launch canceled!
activity代表- 应用程序的界面
layout目录是程序界面的布局(activity)
DemoActivity
03-09 11:43:14.185: E/AndroidRuntime(1093): FATAL EXCEPTION: main
03-09 11:43:14.185: E/AndroidRuntime(1093): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{cn.itcast.helloworld/cn.itcast.helloworld.DemoActivlty}: java.lang.ClassNotFoundException: cn.itcast.helloworld.DemoActivlty in loader dalvik.system.PathClassLoader[/data/app/cn.itcast.helloworld-2.apk]
03-09 11:43:14.185: E/AndroidRuntime(1093): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
03-09 11:43:14.185: E/AndroidRuntime(1093): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-09 11:43:14.185: E/AndroidRuntime(1093): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-09 11:43:14.185: E/AndroidRuntime(1093): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-09 11:43:14.185: E/AndroidRuntime(1093): at android.os.Handler.dispatchMessage(Handler.java:99)
03-09 11:43:14.185: E/AndroidRuntime(1093): at android.os.Looper.loop(Looper.java:123)
03-09 11:43:14.185: E/AndroidRuntime(1093): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-09 11:43:14.185: E/AndroidRuntime(1093): at java.lang.reflect.Method.invokeNative(Native Method)
03-09 11:43:14.185: E/AndroidRuntime(1093): at java.lang.reflect.Method.invoke(Method.java:521)
03-09 11:43:14.185: E/AndroidRuntime(1093): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-09 11:43:14.185: E/AndroidRuntime(1093): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-09 11:43:14.185: E/AndroidRuntime(1093): at dalvik.system.NativeStart.main(Native Method)
03-09 11:43:14.185: E/AndroidRuntime(1093): Caused by: java.lang.ClassNotFoundException: cn.itcast.helloworld.DemoActivlty in loader dalvik.system.PathClassLoader[/data/app/cn.itcast.helloworld-2.apk]
03-09 11:43:14.185: E/AndroidRuntime(1093): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
03-09 11:43:14.185: E/AndroidRuntime(1093): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
03-09 11:43:14.185: E/AndroidRuntime(1093): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
03-09 11:43:14.185: E/AndroidRuntime(1093): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
03-09 11:43:14.185: E/AndroidRuntime(1093): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
03-09 11:43:14.185: E/AndroidRuntime(1093): ... 11 more
由于清单文件的注册表的信息 配置错误 系统找不到对应的activity
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
activity的一个配置信息
作用 在luncher程序里面生成一个应用程序的图标
ctrl+H 搜索整个工程目录 选择file 搜索
03-09 14:32:16.114: ERROR/AndroidRuntime(798): java.lang.SecurityException: Permission Denial:
starting Intent { act=android.intent.action.CALL dat=tel:110 cmp=com.android.phone/.OutgoingCallBroadcaster }
from ProcessRecord{44fc8cf8 798:cn.itcast.phone/10037} (pid=798, uid=10037) requires android.permission.CALL_PHONE
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at android.os.Parcel.readException(Parcel.java:1247)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at android.os.Parcel.readException(Parcel.java:1235)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1298)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at android.app.Activity.startActivityForResult(Activity.java:2817)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at android.app.Activity.startActivity(Activity.java:2923)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at cn.itcast.phone.MainActivity$MyButtonClickListener.onClick(MainActivity.java:40)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at android.view.View.performClick(View.java:2408)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at android.view.View$PerformClick.run(View.java:8816)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at android.os.Handler.handleCallback(Handler.java:587)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at android.os.Handler.dispatchMessage(Handler.java:92)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at android.os.Looper.loop(Looper.java:123)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at java.lang.reflect.Method.invokeNative(Native Method)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at java.lang.reflect.Method.invoke(Method.java:521)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-09 14:32:16.114: ERROR/AndroidRuntime(798): at dalvik.system.NativeStart.main(Native Method)
<uses-permission android:name="android.permission.CALL_PHONE"/>
权限就是用来保护用户隐私的
调试真实手机
1.安装驱动
htc
nexus s
LG
找适合你手机的驱动程序.
豌豆夹 91手机程序
修改图标 fest.xml android:icon="@drawable/xxxxx"
LinearLayout 线性布局
AbsoluteLayout 据对布局
qq斗地主 854*480 apk 800*480 apk
RelativeLayout 相对布局
FrameLayout 帧布局 类似div层
tablelayout 表格布局
在实际开发中,开发android软件的过程需要不断地进行测试。而使用Junit测试框架,侧是正规Android开发的必用技术,在Junit中可以得到组件,可以模拟发送事件和检测程序处理的正确性。
第一步:首先在AndroidManifest.xml中加入下面红色代码:
<manifestxmlns:android="http://schemas.android.com/apk/res/android"
package="cn.itcast.action“ android:versionCode="1“ android:versionName="1.0">
<applicationandroid:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="android.test.runner" />
....
</application>
<uses-sdkandroid:minSdkVersion="6" />
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="cn.itcast.action" android:label="Tests for My App" />
</manifest>
上面targetPackage指定的包要和应用的package相同。
第二步:编写单元测试代码(选择要测试的方法,右键点击“RunAs”--“Android Junit Test” ):
importandroid.test.AndroidTestCase;
importandroid.util.Log;
publicclass XMLTest extends AndroidTestCase {
public void testSomething() throws Throwable {
Assert.assertTrue(1 + 1 == 3);