QQ在线客服
免费咨询热线
400-615-1233
工作时间-工作日
8:30-17:30
立封
平封

Android从入门到精通

内容丰富,案例实用,资源海量
  • 类  别:计算机系列
  • 书  名:Android从入门到精通
  • 主  编:扶松柏
  • 定  价:79.8
  • 开  本:16开
  • 印刷方式:黑白
  • 时  间:2021年11月
  • 出  版  社:北京希望电子出版社
  • 书  号:978-7-83002-510-6

内容摘要

        本书循序渐进、由浅入深地详细讲解了开发Android应用程序的知识,并通过具体实例的实现过程演练了各个知识点的具体应用。
        全书共23章,分别为Android开发基础、剖析Android应用程序、界面UI设计和布局、基本视图组件、事件处理、Activity程序界面、Intent和IntentFilter、Service和BroadcastReceiver、资源管理机制、Android数据存储、绘制二维图形、多媒体音频、开发视频应用程序、使用OpenGL ES开发3D程序、HTTP和URL数据通信、处理XML数据、使用WebView浏览网页、开发移动Web应用程序、GPS地图定位、开发蓝牙应用程序、拍照和二维码识别、网络防火墙系统、在线电话簿管理系统。本书内容讲解细致并且全面,引领读者全面掌握Android开发技术的精髓。
        本书不仅适用于Android开发的初学者,也适用于有一定Android开发基础的读者,还可以作为高等院校相关专业的师生学习用书和培训学校的教材。

目录

第1章 Android开发基础 ·················· 1
 1.1 Android系统简介 ································· 2
  1.1.1 Android 9的新特性 ··················· 2
  1.1.2 Kotlin语言 ································· 2
  1.1.3 Android系统的发展现状 ·········· 3
  1.1.4 Android系统的自身优势 ·········· 3
  1.1.5 Android开发的类别 ·················· 4
 1.2 搭建Android应用开发环境 ················· 5
  1.2.1 安装Android SDK的系统要求 ··········································· 5
  1.2.2 为Java开发做准备:安装JDK ··········································· 5
 1.3 搭建Android Studio开发环境 ·············· 9
  1.3.1 官方方式获取Android Studio工具包 ··········································· 9
  1.3.2 安装工具包 ····························· 11
  1.3.3 启动Android Studio前的设置工作 ········································· 13
  1.3.4 正式启动Android Studio ········ 15
 1.4 第一个Android应用程序实例 ··········· 16
  1.4.1 新建Android工程 ··················· 17
  1.4.2 编写代码和代码分析 ············· 17
  1.4.3 调试程序 ································· 18
  1.4.4 使用模拟器运行项目 ············· 19
  1.4.5 使用真机运行项目 ················· 19
  1.4.6 将Java转换为Kotlin ··············· 22
第2章 剖析Android应用程序 ······ 23
 2.1 Android系统架构 ······························· 24
  2.1.1 应用程序框架层(ApplicationFramework) ·························· 24
  2.1.2 应用程序层(Application) ···25
 2.2 Android应用程序文件组成 ··············· 25
  2.2.1 两种模式 ································· 25
  2.2.2 “app”目录 ····························· 27
  2.2.3 设置文件AndroidManfest.xml···30
  2.2.4 “Gradle Scripts”目录 ············ 32
第3章 界面UI设计和布局 ············ 35
 3.1 使用View视图组件 ···························· 36
  3.1.1 类View的常用属性和方法 ···· 36
  3.1.2 ViewGroup容器 ······················ 37
  3.1.3 类ViewManager ······················ 37
 3.2 UI界面布局的方式 ···························· 38
  3.2.1 使用XML进行布局 ················ 38
  3.2.2 在Java代码中控制布局 ·········· 38
 3.3 使用Android布局管理器 ··················· 40
  3.3.1 使用线性布局LinearLayout ··· 40
  3.3.2 使用相对布局RelativeLayout ···42
  3.3.3 使用帧布局FrameLayout ······· 45
  3.3.4 使用表格布局TableLayout ····· 46
  3.3.5 使用绝对布局 AbsoluteLayout ····48
  3.3.6 使用网格布局GridLayout ······ 49
第4章 基本视图组件 ······················ 51
 4.1 使用Widget组件 ································· 52
  4.1.1 Widget框架类的组成 ············· 52
  4.1.2 实战演练:使用Widget组件 ········································· 52
  4.1.3 实战演练:使用Button按钮组件 ········································· 53
  4.1.4 实战演练:使用TextView文本框组件 ····································· 54
  4.1.5 实战演练:使用EditText编辑框组件 ········································· 55
  4.1.6 实战演练:使用CheckBox多项选择组件 ································· 56
  4.1.7 实战演练:使用单项选择组件RadioGroup ····························· 57
  4.1.8 实战演练:使用Spinner下拉列表组件 ····································· 58
  4.1.9 实战演练:使用AutoCompleteTextView自动完成文本组件 ··· 59
  4.1.10 实战演练:使用DatePicker日期选择器组件 ······················ 61
  4.1.11 实战演练:使用TimePicker时间选择器组件 ······················ 61
  4.1.12 实战演练:使用ScrollView滚动视图组件 ·························· 62
  4.1.13 实战演练:使用ProgressBar进度条组件 ······························ 63
  4.1.14 实战演练:使用SeekBar拖动条组件 ·································· 64
  4.1.15 实战演练:使用RatingBar评分组件 ·································· 64
  4.1.16 实战演练:使用ImageView图片视图组件 ·························· 65
  4.1.17 实战演练:使用网格视图组件GridView ··························· 66
  4.1.18 实战演练:使用ImageSwitcher图片切换器组件 ·························67
  4.1.19 实战演练:使用HorizontalScrollView水平滑动组件 ·············· 68
 4.2 使用MENU菜单组件 ························· 70
  4.2.1 MENU组件基础 ····················· 70
  4.2.2 实战演练:使用MENU组件 ···71
 4.3 使用列表组件ListView ······················ 72
  4.3.1 Adapter介绍 ···························· 73
  4.3.2 ListView基础 ·························· 73
  4.3.3 实战演练:使用SimpleAdapter方式实现ListView列表 ·········· 74
 4.4 使用Toast和Notification通知组件 ····· 75
  4.4.1 使用Toast通知 ························ 75
  4.4.2 使用Notification通知 ·············· 76
  4.4.3 实战演练:使用Toast通知的5种用法 ····································· 77
第5章 事件处理 ································ 79
 5.1 基于监听的事件处理························· 80
  5.1.1 监听处理模型中的三种对象 ········································· 80
  5.1.2 实战演练:单击按钮事件处理程序 ········································· 81
  5.1.3 Android系统中的监听事件 ···· 83
 5.2 实现事件监听器的方法····················· 84
  5.2.1 内部类形式 ····························· 84
  5.2.2 实战演练:使用外部类形式定义事件监听器 ························· 84
  5.2.3 实战演练:将Activity本身作为事件监听器类 ························· 86
 5.3 基于回调的事件处理························· 87
  5.3.1 Android事件侦听器的回调方法 ········································· 87
  5.3.2 实战演练:使用基于回调的事件处理机制 ····························· 89
  5.3.3 实战演练:使用基于回调的事件传播 ····································· 91
  5.3.4 重写onTouchEvent方法响应触摸屏事件 ································· 92
 5.4 系统设置事件····································· 92
  5.4.1 Confi guration类基础 ··············· 93
  5.4.2 实战演练:获取系统的屏幕方向和触摸屏方式 ····················· 93
第6章 Activity程序界面 ················ 96
 6.1 Activity基础 ········································ 97
  6.1.1 Activity的状态及状态间的转换 ········································· 97
  6.1.2 实战演练:使用Activity覆盖7个生命周期 ····························· 98
 6.2 启动Activity ···································· 102
  6.2.1 实战演练:使用LauncherActivity启动Activity列表 ··························102
  6.2.2 实战演练:使用ExpandableListActivity生成一个可展开列表窗口 ······································· 104
  6.2.3 实战演练:使用PreferenceActivity设置界面 ········································105
  6.2.4 实战演练:通过Activity数据交换开发会员注册系统 ··········· 107
 6.3 Activity的加载模式 ·························· 109
  6.3.1 四种加载模式 ······················· 109
  6.3.2 实战演练:使用singleInstance加载模式 ······························· 110
 6.4 使用Fragment ··································· 112
  6.4.1 Fragment的设计理念 ··········· 112
  6.4.2 创建Fragment ······················· 112
  6.4.3 实战演练:使用Fragment实现图书展示系统 ······················· 114
第7章 Intent和IntentFilter ··········· 117
 7.1 Intent和IntentFilter基础 ··················· 118
  7.1.1 Intent启动不同组件的方法 ······································· 118
  7.1.2 Intent的构成 ························· 119
  7.1.3 实战演练:在一个Activity中调用另一个Activity ················· 119
 7.2 使用IntentFilter ································ 121
  7.2.1 IntentFilter基础 ····················· 121
  7.2.2 IntentFilter响应隐式Intent ··· 122
  7.2.3 实战演练:一个拨打电话程序 ······································· 124
 7.3 Intent的属性 ····································· 125
  7.3.1 实战演练:使用Component属性介绍 ··································· 125
  7.3.2 实战演练:Action属性 ········ 127
  7.3.3 实战演练:使用Category属性 ······································· 131
第8章 S e r v i c e和B r o a d c a s tReceiver ······························ 134
 8.1 后台服务Service ······························· 135
  8.1.1 Service介绍 ·························· 135
  8.1.2 实战演练:创建、启动和停止Service ··································· 135
  8.1.3 设置Service的访问权限 ······· 138
  8.1.4 实战演练:绑定后台Service服务 ······································· 138
 8.2 AIDL实现跨Service交互 ················· 140
  8.2.1 AIDL基础 ····························· 141
  8.2.2 实战演练:在客户端访问AIDL Service ··································· 141
 8.3 使用Broadcast Receiver接收信息 ··· 143
  8.3.1 BroadcastReceiver基础 ········· 143
  8.3.2 实战演练:发送广播信息 ··· 144
 8.4 短信处理··········································· 146
  8.4.1 SmsManager类介绍 ·············· 146
  8.4.2 实战演练:实现一个发送短信系统 ······································· 148
 8.5 拨打电话处理··································· 150
  8.5.1 TelephonyManager类介绍 ···· 150
  8.5.2 实战演练:来电后自动发送邮件通知 ··································· 151
第9章 资源管理机制 ···················· 153
 9.1 Android的资源类型 ························· 154
 9.2 使用资源的3种方式························· 155
  9.2.1 在Java代码中使用资源清单项 ······································· 155
  9.2.2 在XML代码中使用资源 ······ 155
  9.2.3 实战演练:联合使用字符串、颜色和尺寸资源 ··················· 156
 9.3 使用Drawable(图片)资源 ··········· 157
  9.3.1 使用StateListDrawable资源 ······································· 157
  9.3.2 使用LayerDrawable资源 ······ 158
  9.3.3 使用ShapeDrawable资源 ····· 159
  9.3.4 使用ClipDrawable资源 ········ 160
  9.3.5 使用AnimationDrawable资源 ······································· 160
 9.4 使用XML资源 ·································· 162
  9.4.1 Android操作XML文件 ········· 162
  9.4.2 实战演练:解析原始XML文件 ······································· 162
 9.5 使用样式资源和主题资源··············· 163
  9.5.1 使用样式资源 ······················· 163
  9.5.2 使用主题资源 ······················· 164
  9.5.3 实战演练:使用主题资源 ······································· 164
 9.6 使用其他类型的资源······················· 166
  9.6.1 实战演练:使用属性资源 ··· 166
  9.6.2 实战演练:使用声音资源 ··· 169
第10章 Android数据存储 ··········· 171
 10.1 使用SharedPreferences存储 ··········· 172
  10.1.1 SharedPreferences简介 ······· 172
  10.1.2 实战演练:使用SharedPreferences存储联系人信息 ··························172
 10.2 文件存储········································· 174
  10.2.1 文件存储介绍 ····················· 174
  10.2.2 实战演练:实现一个掌上日记本系统···························· 174
 10.3 使用SQLite技术 ····························· 176
  10.3.1 SQLite基础 ························· 176
  10.3.2 SQLiteOpenHelper辅助类 ································· 176
  10.3.3 实战演练:使用SQLite存储并操作数据 ····························· 177
 10.4 ContentProvider存储 ······················ 180
  10.4.1 ContentProvider介绍 ·········· 180
  10.4.2 实战演练:获取通讯录中的联系人信息 ······················· 181
 10.5 网络存储········································· 184
  10.5.1 Web Service介绍 ················· 184
  10.5.2 实战演练:开发一个天气预报系统 ······························· 184
第11章 绘制二维图形 ·················· 187
 11.1 Skia渲染引擎介绍 ·························· 188
 11.2 使用画布绘制图形 ························· 188
  11.2.1 Canvas画布 ························· 188
  11.2.2 实战演练:使用画布绘制二维图形 ······························· 189
 11.3 使用画笔绘制图形 ························· 191
  11.3.1 Paint类基础 ························· 191
  11.3.2 实战演练:使用类Color和类Paint绘制图形 ··················· 191
 11.4 使用位图操作类绘制图形 ············· 192
  11.4.1 类Bitmap基础 ····················· 192
  11.4.2 实战演练:使用类Bitmap实现模拟水纹效果 ···················· 193
 11.5 设置文本颜色 ································· 195
  11.5.1 类Color基础 ························ 195
  11.5.2 实战演练:使用类Color更改文字的颜色 ························ 196
 11.6 使用矩形类Rect和RectF ················ 197
  11.6.1 类Rect基础 ·························· 197
  11.6.2 类RectF基础 ······················· 198
  11.6.3 实战演练:使用类Rect和类RectF绘制矩形 ·················· 199
 11.7 使用变换处理类Matrix ·················· 201
  11.7.1 类Matrix基础 ······················ 201
  11.7.2 实战演练:使用类Matrix实现图片缩放功能 ····················· 201
 11.8 使用BitmapFactory类 ····················· 203
  11.8.1 类BitmapFactory基础 ········· 203
  11.8.2 实战演练:获取指定图片的宽度和高度 ······················· 204
 11.9 使用Tween Animation创建二维动画················································· 205
  11.9.1 Tween动画基础 ·················· 205
  11.9.2 实战演练:实现Tween动画的4种效果 ······························ 206
 11.10 实现Frame Animation(帧动画)效果··············································· 207
  11.10.1 Frame动画基础 ················· 207
  11.10.2 实战演练:实现Frame动画效果 ·································· 208
 11.11 使用Property Animation(属性动画)··········································· 209
  11.11.1 Property Animation(属性)动画基础 ··························· 209
  11.11.2 实战演练:实现属性动画效果 ··································· 210
第12章 多媒体音频 ······················· 211
 12.1 核心功能类AudioManager ············ 212
  12.1.1 AudioManager基础 ············· 212
  12.1.2 实战演练:设置短信提示铃声 ····································· 212
 12.2 实现录音功能································· 214
  12.2.1 MediaRecorder接口基础 ···· 214
  12.2.2 实战演练:录制并播放录制的音频 ····································· 215
 12.3 使用MediaPlayer播放音频 ············ 218
  12.3.1 MediaPlayer基础 ················ 218
  12.3.2 实战演练:使用MediaPlayer播放音频 ···························· 218
 12.4 使用SoundPool播放音频 ··············· 220
  12.4.1 SoundPool基础 ··················· 220
  12.4.2 实战演练:使用SoundPool播放长短不一的音效 ········· 220
 12.5 使用Ringtone播放铃声 ·················· 221
  12.5.1 类RingtoneManager基础 ···· 221
  12.5.2 实战演练:使用RingtoneManager设置手机铃声 ······ 222
 12.6 实现手机振动功能························· 223
  12.6.1 Vibrator类基础···················· 223
  12.6.2 实战演练:使用Vibrator实现手机振动 ···························· 224
 12.7 设置闹钟········································· 225
  12.7.1 AlarmManage基础 ·············· 225
  12.7.2 实战演练:开发一个闹钟简单的闹钟程序 ················· 226
第13章 开发视频应用程序 ······· 228
 13.1 实战演练:使用MediaPlayer播放视频················································· 229
 13.2 使用VideoView播放视频 ··············· 231
  13.2.1 VideoView基础 ··················· 231
  13.2.2 实战演练:使用VideoView播放手机中的影片 ············· 233
第14章 使用OpenGL ES开发3D程序 ···································· 235
 14.1 OpenGL ES介绍 ····························· 236
 14.2 使用点线法绘制三角形················· 236
  14.2.1 点线法基础 ························· 236
  14.2.2 实战演练:使用GL_TRIANGLES方法绘制三角形 ···························237
 14.3 使用索引法绘制三角形················· 239
  14.3.1 gl.glDrawElements()方法基础 ····································· 239
  14.3.2 实战演练:使用索引法绘制三角形 ························· 239
 14.4 实现投影效果································· 241
  14.4.1 正交投影和透视投影 ········· 241
  14.4.2 实战演练:在Android屏幕中实现投影效果 ····················· 242
 14.5 实现光照效果································· 243
  14.5.1 光源的类型 ························· 243
  14.5.2 实战演练:开启或关闭光照特效 ····································· 244
 14.6 实现纹理映射································· 247
  14.6.1 纹理贴图和纹理拉伸 ········· 247
  14.6.2 实战演练:实现三角形纹理贴图效果 ····················· 248
 14.7 实现坐标变换································· 251
  14.7.1 坐标变换基础 ····················· 251
  14.7.2 实战演练:实现平移变换效果 ····························· 251
 14.8 使用Alpha混合技术 ······················· 253
  14.8.1 Alpha混合基础 ··················· 253
  14.8.2 实战演练:实现光晕和云层效果 ····························· 254
第15章 HTTP和URL数据通信 ······································ 256
 15.1 HTTP协议开发······························· 257
  15.1.1 Android中的HTTP ·············· 257
  15.1.2 实战演练:在手机屏幕中传递HTTP参数 ··················· 258
 15.2 URL和URLConnection ·················· 260
  15.2.1 URL类基础 ························· 261
  15.2.2 实战演练:从网络中下载图片作为屏幕背景 ············· 262
 15.3 使用HTTPURLConnection访问网络资源········································· 264
  15.3.1 HttpURLConnection的主要用法 ····································· 264
  15.3.2 实战演练:显示网络中的图片 ····································· 268
第16章 处理XML数据 ················· 270
 16.1 XML技术基础 ································ 271
 16.2 使用SAX解析XML数据 ················ 272
  16.2.1 SAX基础 ····························· 272
  16.2.2 实战演练:使用SAX解析XML数据 ···························· 272
 16.3 使用DOM解析XML ······················ 275
  16.3.1 DOM基础 ··························· 275
  16.3.2 实战演练:使用DOM技术来解析并生成XML ············ 275
 16.4 使用Pull解析技术 ·························· 278
  16.4.1 Pull解析原理 ······················ 278
  16.4.2 实战演练:使用Pull解析并生产XML文件 ···················· 278
  16.4.3 实战演练:开发一个音乐客户端 ································· 280
第17章 使用WebView浏览网页 ····283
 17.1 WebView基础 ································· 284
  17.1.1 WebView的优点 ················· 284
  17.1.2 WebSettings管理接口 ········· 284
  17.1.3 Web视图客户对象 ·············· 284
  17.1.4 客户基类WebChromeClient ····285
 17.2 使用WebView的3种方式 ··············· 286
  17.2.1 实战演练:浏览指定网址的网页信息 ····························· 286
  17.2.2 实战演练:加载显示指定的HTML程序 ························· 288
  17.2.3 实战演练:实现与JavaScript的交互 ································· 289
第18章 开发移动Web应用程序 ···293
 18.1 实战演练:编写一个适用于Android系统的网页····································· 294
  18.1.1 控制页面的缩放 ················· 296
  18.1.2 添加Android的CSS ············ 297
  18.1.3 添加JavaScript ···················· 299
 18.2 实战演练:使用Ajax技术 ············· 302
 18.3 让网页动起来································· 305
  18.3.1 实战演练:使用JQTouch框架开发网页 ····························· 306
  18.3.2 实战演练:使用PhoneGap框架开发网页 ····················· 309
第19章 GPS地图定位 ··················· 315
 19.1 使用位置服务································· 316
  19.1.1 android.location功能类 ······· 316
  19.1.2 实战演练:使用GPS定位技术获取当前的位置信息 ········· 318
 19.2 及时更新位置信息························· 320
  19.2.1 使用LocationManager监听位置 ····································· 320
  19.2.2 实战演练:监听当前设备的坐标、高度和速度 ············· 321
 19.3 在Android设备中使用谷歌地图 ··· 323
  19.3.1 Google Maps Android API开发基础 ····································· 323
  19.3.2 类MapFragment ·················· 324
  19.3.3 申请SHA1认证指纹和GoogleMaps API V2 Android密钥 328
  19.3.4 使用Google Map API密钥 · 330
  19.3.5 实战演练:在谷歌地图中定位显示当前的位置 ··········· 333
  19.3.6 实战演练:根据给定坐标在地图中显示位置 ················· 336
 19.4 使用百度地图································· 337
  19.4.1 百度Android定位SDK介绍 ····································· 337
  19.4.2 使用百度Android定位SDK ····································· 338
  19.4.3 实战演练:在百度地图中定位显示当前的位置 ········· 341
 19.5 使用高德地图································· 343
  19.5.1 使用高德地图 ····················· 343
  19.5.2 实战演练:使用高德地图定位显示当前的位置 ········· 350
第20章 开发蓝牙应用程序 ········ 353
 20.1 蓝牙4.0 BLE介绍 ··························· 354
 20.2 和蓝牙相关的类····························· 354
  20.2.1 蓝牙套接字类BluetoothSocket ································· 354
  20.2.2 服务器监听接口类BluetoothServerSocket ······················· 356
  20.2.3 蓝牙适配器类B l u e t o o t hAdapter ···························· 356
  20.2.4 服务端常量类BluetoothClass.Service ······························· 365
  20.2.5 定义设备常量类BluetoothClass.Device ····················· 365
 20.3 开发Android蓝牙应用程序 ··········· 366
  20.3.1 实战演练:开发一个控制玩具车的蓝牙遥控器 ··········· 366
  20.3.2 实战演练:开发一个Android蓝牙控制器 ························ 368
第21章 拍照和二维码识别 ········ 372
 21.1 调用系统内置的拍照功能············· 373
  21.1.1 开启权限 ······························· 373
  21.1.2 Camera2中的主要接口 ········ 373
 21.2 使用Camera API ····························· 374
  21.2.1 使用Camera API方式拍照 ····································· 374
  21.2.2 实战演练:自己开发的拍照程序 ····································· 375
 21.3 全新的Camera2 API ······················· 376
  21.3.1 Camera2 API介绍 ··············· 377
  21.3.2 实战演练:使用Camera 2 API实现预览和拍照功能 ········· 379
 21.4 解析二维码····································· 381
  21.4.1 QR Code码的特点 ·············· 381
  21.4.2 实战演练:在早期版本使用相机解析二维码 ················· 381
  21.4.3 实战演练:使用开源框架Zxing生成二维码 ··············· 384
第22章 网络防火墙系统 ············· 391
 22.1 系统需求分析································· 392
 22.2 编写布局文件································· 392
 22.3 编写主程序文件····························· 395
  22.3.1 主Activity文件 ···················· 395
  22.3.2 帮助Activity文件 ················ 408
  22.3.3 公共库函数文件 ················· 409
  22.3.4 系统广播文件 ····················· 421
  22.3.5 登录验证 ····························· 422
  22.3.6 打开/关闭某一个实施控件 ····································· 424
第23章 在线电话簿管理系统 ··· 428
 23.1 实例目标········································· 429
 23.2 PhoneGap简介 ································ 430
  23.2.1 产生背景介绍 ····················· 430
  23.2.2 什么是PhoneGap ················ 431
  23.2.3 搭建PhoneGap开发环境 ···· 431
 23.3 具体实现········································· 433
  23.3.1 创建Android工程 ··············· 433
  23.3.2 实现系统主界面 ················· 435
  23.3.3 实现信息查询模块 ············· 437
  23.3.4 实现系统管理模块 ············· 439
  23.3.5 实现信息添加模块 ············· 444
  23.3.6 实现信息修改模块 ············· 447
  23.3.7 实现信息删除模块和更新模块 ····································· 450

相关图书