过编写基于安卓系统的应用程序,可以发现安卓为开发者提供了便利的开发环境,大量开发者能够由此开发出自己心仪的应用程序,也因此安卓拥有如此大的生态
摘要:随着信息技术的发展,智能手机的普及,人们的生产生活发送发生了很大的变化。今天人们可以在相距甚远的地方互相交流,及时地发送紧急信息,这极大的改善了人们的生活与工作水平。而手机这种移动终端也被做的越来越小型化,功能也越来越多,基于安卓操作系统的手机就是其中的一个代表。安卓是基于Linux内核适用于移动设备的操作系统,它被广泛应用于今天的智能手机上。
本课题是以使用安卓操作系统的手机为平台而设计的,它介绍了一些网络通信的基础知识,安卓开发的流程和安卓操作系统的框架,还有一部分与安卓开发有关的Java方面的情况。
本课题的主要内容有两部分,一是客户端的设计,它主要需要安卓应用程序的界面设计,建立客户端的Socket连接。主要功能是提供给用户输入界面并把输入数据向服务端发送。二是服务端的设计,它需要建立服务端的Socket连接,主要功能是接受来自客户端的数据并将数据向控制台输出。
关键词: 安卓;Socket;TCP;多线程;I/O流
Design of data communication system based on Android
Abstract:With the development of information technology and the popularization of smart phones, great changes have taken place in people's production and life. Today, people can communicate with each other far away and send emergency information in a timely manner. This greatly improves people's lives and work. Mobile phones such as mobile phones have also been made more and more compact and have more and more functions. Android-based mobile phones are among them. Android is based on the Linux kernel operating system for mobile devices, it is widely used in today's smart phones.
This topic is designed using a mobile phone using the Android operating system as a platform. It introduces some basic knowledge of network communication, the Android development process and the framework of the Android operating system, and some aspects related to Java development of Android development.
The main content of this topic has two parts, one is the design of the client, it mainly needs the design of the interface of the Android application, and establishes the Socket connection of the client. The main function is to provide the user with an input interface and send the input data to the server. The second is the design of the server. It needs to establish a Socket connection on the server. The main function is to accept data from the client and output the data to the console.
KeyWords: Android;Socket;TCP;multithreaded;I/O flow
目 录
1 绪论 1
1.1 课题的目的和意义 1
1.2 国内外研究现状与水平 1
1.2.1 安卓操作系统现状 1
1.2.2 通信软件现状 1
1.2.3 发展趋势 1
1.3 本课题的主要内容 2
2 网络通信基础 3
2.1 TCP/IP基础 3
2.2 Socket 4
2.2.1 ServletSocket 4
2.2.2 Socket的使用 4
2.3 安卓开发流程 5
2.3.1 搭建安卓应用开发环境 5
2.3.2 安卓的包文件及系统架构 5
2.3.3 模拟器的配置 7
2.3.4 应用包的安装 8
2.4 C/S结构 8
3 客户端设计 10
3.1 程序设计 10
3.2 设计UI界面 10
3.2.1 布局管理器 10
3.2.2 使用XML文件控制布局文件 11
3.3 Java异常处理 12
3.3.1 异常 12
3.3.2 Java的异常处理机制 13
3.3.3 异常的处理 13
3.4 I/O流 13
3.4.1 数据流 13
3.4.2 InputStream/OutputStream 14
3.4.3 BufferedInputStream/BufferedOutputStream 15
3.5 客户端中的类与方法 16
3.5.1 MainActivity类 16
3.5.2 MyThread 16
3.5.3 客户端中的方法 16
4 服务端设计 17
4.1 程序设计 17
4.2 多线程 17
4.2.1 线程 17
4.2.2 TCP中的多线程 17
5 系统调试及运行 19
5.1 运行结果 19