安卓期末复习大纲(全)

第1章概述
一、知识点
1、常见的智能手机操作系统:iPhoneOS、Android、Symbian等。
2、Android体系结构:
二、应用
1、简述Android体系结构,并说明各层次的作用。
答:Android是基于Linux内核的软件平台和操作系统,共分为四层。
第一层是Linux内核及文件系统。Linux内核是硬件和其他软件堆层之间的一个抽象隔离层,提供由操作系统内核管理的底层基础功能,主要有安全机制、内存管理、进程管理、网络协议校和驱动程序等。
第二层是Android函数库及运行时。
第三层是应用程序框架层。提供了Android平台的管理功能和组件重用机制,包括Activity管理、资源管理、位置管理、通知消息管理、View系统和内容提供者等。
第四层是应用程序层。提供了一系列核心应用程序,如打电话、浏览器、联系人、相册、地图和电子市场等。

第2章Android开发环境
一、知识点
1、Android开发环境所需软件:
① JDK(Java开发工具包)、Eclipse(集成开发软件)、Android SDK(android软件开发工具包)、ADT(android开发工具)
② JDK(Java开发工具包)、 Androidstudio
2、Android手机模拟器AVD、Android系统调试工具DDMS、日志浏览器LogCat
3、ADB:安卓调试桥

第3章Android应用程序结构
一、知识点
1、Android工程的文件系统结构
源程序文件夹src,
资源文件夹res、assets、gen,
编译文件夹bin,
依赖包文件夹libs,
工程配置清单文件AndroidManifest.xml,
布局文件夹res/layout
2、Android四大组件:Activity、Service、BroadcastReceiver、ContentProvider
二、应用
1、在Android工程的文件系统结构中,请简述文件夹src、res/Layout以及文件AndroidManifest.xml的用途。
答:源程序文件夹src,用于存放Java源程序文件。
res/Layout用于存放扩展名为.xml的布局文件。
工程配置清单文件AndroidManifest.xml用于配置Android系统运行前必须掌握的相关信息,例如:应用程序名称、组件注册、授权等。

2、简述Android的四大组件名称,并说明它们的功能。
答:Android应用程序划分为四类核心组件,即Activity、Service、Broadcast Receiver和ContentProvider。其中,Activity是Android最重要的组件,负责用户界面的设计。Service是Android提供的长时间在后台运行的无用户界面组件。BroadcastReceiver,即广播接收者,用来接收广播,并做出回应。ContentProvider,对共享数据进行增删改查等操作。

4、试比较Activity和Service的异同点。
答:相同点:都是Android四大核心组件之一。
不同点:(1)功能。Activity是Android最重要的组件,负责用户界面的设计,在清单文件中使用标签<activity>注册。Service是Android提供的长时间在后台运行的无用户界面组件,在清单文件中使用标签注册。(2)生命周期。Activity生命周期比Service长。(3)启动方式。Service能以绑定的方式启动。

4、阅读程序,回答问题。
1. <uses-permission android:name=”android.permission.INTERNET”
2.
2. <activity android:name=“.IntentDemo”
3. android:label=“@string/app_name”>
4.
5.
6.
7.
8.
9. <activity android:name=“.NewActivity”
10. android:label=“@string/app_name”>
11.
12.
答:该代码是一个工程配置清单文件AndroidManifest.xml,注册了两个activity(IntentDemo,NewActivity),程序运行时首先启动IntentDemo这个activity。在配置清单文件中配置了访问Internet的权限。

第4章 Android应用开发基础
一、知识点
1、常用控件
文本框控件TextView和EditText、
显示图像控件ImageView、
命令按钮控件Button和ImageButton、
单选控件RadioButton、
复选控件CheckBox、
对话框控件AlertDialog、
进度控件ProgressDialog、
列表控件ListView、
菜单Menu,等等。
2、常用布局
线性布局LinearLayout、
相对布局RelativeLayout、
帧布局,等。
3、用户界面事件
点击事件、 按键事件、触摸事件。
4、文件存储
SharedPreferences存储、内部存储、外部存储。
5、意图类Intent
用途:启动组件、组件之间传递数据。
分类:显式启动、隐式启动。
二、应用
1、在用户界面设计中,常用的控件有哪些? 请举例5个并简述他们的用途。
答:文本框控件TextView和EditText,用来输入和编辑字符的控件。
显示图像控件ImageView,用来显示图像。
按钮控件Button,用来定义命令按钮,绑定和响应事件。
RadioButton是单选按钮控件。
复选控件CheckBox是复选按钮控件。

2、阅读程序,回答问题。

  1. <LinearLayout
  2.  xmlns:android="http://schemas.android.com/apk/res/android"
    
  3.  android:layout_width="fill_parent"
    
  4.  android:layout_height="wrap_content"
    
  5.  android:orientation="vertical">        
    
  6.  <TextView android:id="@+id/label"      
    
  7.      android:layout_width="wrap_content"     
    
  8.          android:layout_height="wrap_content" 
    
  9.          android:text="用户名:" >
    
  10. </TextView>
    
  11. <EditText android:id="@+id/entry"               
    
  12.     android:layout_height="wrap_content" 
    
  13.     android:layout_width="fill_parent">      
    
  14. </EditText>
    
  15. <Button android:id="@+id/ok" 
    
  16.     android:layout_width="wrap_content" 
    
  17.     android:layout_height="wrap_content" 
    
  18.     android:text="确认">
    
  19. </Button>	
    

答:本代码是用户布局文件,采用线性布局LinearLayout(竖直vertical),使用了TextView、EditText、Button等三种控件,wrap_content表示控件的宽度等于包含内容的宽度,fill_parent表示控件的宽度等于父控件的宽度。该界面布局的效果图为:

3、阅读程序,回答问题。

  1. Button button = (Button)findViewById(R.id.btn);
  2. button.setOnClickListener(new OnClickListener(){
  3. public void onClick(View view){
  4.   Intent intent = new Intent(IntentDemoActivity.this, NewActivity.class );
    
  5.   startActivity( intent );	}
    

答:该代码的功能是单击命令按钮,由用户界面IntentDemoActivity跳转到NewActivity,它采用Intent机制,以显式启动来启动另一个Activity。

5、文件读写

  1. public static final String PREFERENCE_NAME = "SaveSetting";
    
    1. public static int MODE = Context.MODE_WORLD_READABLE +    
      
  2.                Context.MODE_WORLD_WRITEABLE;
    
  3. private void saveSharedPreferences(){
    
  4.    SharedPreferences sharedPreferences =     
    
  5.       getSharedPreferences(PREFERENCE_NAME, MODE);
    
  6.    SharedPreferences.Editor editor = sharedPreferences.edit();  	    
    
  7.    editor.putString("Name", nameText.getText().toString());
    
  8.    editor.putInt("Age", Integer.parseInt(ageText.getText().toString()));
    
  9.   editor.putFloat("Height", Float.parseFloat(heightText.getText().toString()));
    
  10.   editor.commit();
    
  11. }
    答:该代码是采用SharedPreferences存储方式来进行写文件,其中文件名为SaveSetting,全局读写模式(MODE_WORLD_READABLE+ MODE_WORLD_ WRITEABLE),输入的数据有Name、Age、Height,commit()方法表示将数据提交。

第5章 手机基本功能程序设计
一、知识点
1、手机基本功能经有:打电话、发短信、媒体播放、录音、拍照、二维码扫描
2、短信发送权限:android.permission.SEND_SMS

第6章 服务组件与广播组件
一、知识点
1、服务Service启动
服务的显式启动和隐式启动,绑定服务启动。
2、分类;本地服务与远程服务。
3、广播BroadCast和广播接受者BroadCastReceiver。

二、应用
public class MyAudioService extends Service {
public class PlayBinder extends Binder{
public void MyMethod( ){
String path=“sdcard/Music/white.mp3”;
MediaPlayer mediaplayer=new MediaPlayer( );
try {
mediaplayer.setDataSource(path);
mediaplayer.prepare( );
mediaplayer.start( ); }
catch (IOException e) { e.printStackTrace( ); }
}
}
@Override
public IBinder onBind(Intent arg0) {
return new PlayBinder ( );
}
}
public class MainActivity extends Activity {
private ServiceConnection conn = new ServiceConnection( ) {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
PlayBinder myAudioBinder = (MyAudioService.PlayBinder) service;
myAudioBinder.MyMethod( );
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(this, MyAudioService.class);
bindService( intent , conn , BIND_AUTO_CREATE);
}
}
第7章 SQLite数据库编程
一、知识点
1、SQLite数据库,使用抽象类SQLiteOpenHelper创建、打开或更新数据库。
2、数据库的四种操作:查询select、插入insert、更新update、删除delete。
二、应用
class MyDbOpenHelper extends SQLiteOpenHelper{
public MyDbOpenHelper(Context context) {
super(context, “test.db”, null,1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(“CREATE TABLE person(id INTEGER PRIMARY KEY
+AUTOINCREMENT, name VARCHAR(20))”);
db.execSQL(“insert into person values(null,‘Wu’)”);
db.execSQL(“insert into person values(null,‘Guan’)”);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL(“ALTER TABLE person ADD tel INTEGER”);
db.execSQL(“update person set tel=15527643858 where name=‘Wu’”);
db.execSQL(“update person set tel=13308628750 where name=‘Guan’”);
}
}
利用辅助类SQLiteOpenHelper创建和打开更新数据库;数据库名称:test.db,版本为:1; 创建具有两个字段(id,name)的表person;id为自增组件,向表person中插入数据(姓名为Wu,Guan)。

第8章 数据共享
一、知识点
1、ContentProvider组件:内容提供者,对共享数据进行增删改查等操作
2、ContentResolver类:内容解析器,通过其去解析数据。
3、读取手机联系人信息的权限:android.permission.READ_CONTACTS

第9章 近距离通信
一、知识点
1、Android设备之间的近距离通信有:WIFI通信、蓝牙Bluetooth通信、近场NFC通信
2、使用WiFi的两个权限:android.permission.CHANGE_WIFI_STATE
android.permission.ACCESS_WIFI_STATE

第10章 位置服务与地图应用开发
一、知识点
1、位置服务
三种定位方式:GPS定位、WIFI定位、基站定位
2、地图应用
常用地图有:谷歌地图、百度地图
3、使用GPS的权限:android.permission.ACCESS_FINE_LOCATION

二、应用
1、阅读程序,回答问题;
String serviceString = Context.LOCATION_SERVICE;
LocationManager locationManager = (LocationManager)getSystemService(serviceString);
String provider = LocationManager.GPS_PROVIDER;
Location location = locationManager.getLastKnownLocation(provider);
double longitude = location.getLongitude();
double latitude = location.getLatitude();
答:该代码是提供位置服务,其中,定位方式是GPS定位,longitude表示设备的经度, latitude表示设备的纬度。

2、阅读程序,回答问题;
LocationManager lm =(LocationManager) this.getSystemService(Context.LOCATION_ SERVICE);
if(! lm.isProviderEnabled(lm.GPS_PROVIDER)){//判断是否开启定位权限,没有的话加入设置页面开启定位
Intent myintent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity( myintent ); }
btn_listen=(Button) findViewById(R.id.btn_listen);
btn_listen.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new MyLocation()); } //采用GPS定位服务,不断监听位置变化,实时更新,第二三个参数表示GPS更新的间隔的最短时间和最短距离
}
});
class MyLocation implements LocationListener{
@Override
public void onLocationChanged(Location location ) {
tv_01.setText(“您当前位置的经度为:”+location.getLongitude());
tv_02.setText(“您当前位置的纬度为:”+location.getLatitude());
}
}

第11章 Android网络编程
一、知识点
1、Android网络编程
分为两类:应用层的HTTP编程、运输层的Socket编程
2、HTTP请求方式
两种:Get请求方式、Post请求方式
二、应用
1、阅读程序,回答问题;
String requestUrl = “http://www.hncu.net”;
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(requestUrl);
List params = new ArrayList();
params.add(new BasicNameValuePair(“mobileCode”, phoneSec));
params.add(new BasicNameValuePair(“userId”, “”));
try {
post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
HttpResponse response = client.execute(post);
String result=“”;
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
result = EntityUtils.toString( response.getEntity(),“utf-8”);
}
else{
result =“没有查询结果”;
}
} catch (Exception e) {
e.printStackTrace();
}
答:该代码是从网站www.hncu.net查询数据。其中,使用Apache下的HttpClient编程,Post请求方式,上传的数据有mobileCode和userId,查询结果存放在result。

  • 9
    点赞
  • 96
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值