1.Android 框架组成部分
a)Application
b)Application FrameWork
c)Libraries
d)Driver
2.环境搭建:JDK、ADT、SDK、Eclipse
名词解释:JDK
JRE
ADT
DDMS
ADB
AVD
3.ADB 常用命令
安装、卸载
导入、导出
启动模拟器
Linux: shell 常用命令
DOS-->Shell
Shell-->Dos
4.五种布局:(常用属性)
LinearLayout:
RelativeLayout
AbsoluteLayout
TableLayout
FrameLayout
5.常用组件:(常用属性,以及监听)
TextView
ImageView
Button
ImageButton
EditText
CheckBox
RadioButton
TextSwitcher
ImageSwitcher
ToggleButton
Spinner
Gallery
TimePicker
DatePicker
SlidingDraw
ExpandableListView
RatingBar
ProgressBar
SeekBar
AlertDialog(自定义对话框布局以及自定义对话框组件)
Toast(自定义Toast)
6.Menu(两种方式创建菜单xml和Java代码、监听)
OptionMenu
SubMenu
ContextMenu(注册 registerforContextMenu)
7.重要组件
ListView和GridView(增删改查)
8.适配器
ArrayAdapter List Array
SimpleAdapter List<Map<String,Object>>
SimpleCursorAdapter cursor
BaseAdapter List<Object> 四个方法
9.Activity 概念
1)四种状态: 运行态、暂停态、停止态、销毁态 可以从能够看到界面以及获得焦点(交互)
2) 生命周期
七个方法:1onCreate 2onStart 3onResume 4onPause 5onStop 6onRestrat 7onDestroy
点击图标: 1、2、3
跳转:完全覆盖 4、5 半透明 4(对话框)
返回按钮:3
点击home键 4、5 再次点击图标: 6 、2、3
点击返回按钮:4、5、7
onSaveInstanceState ( ) :
手机横竖屏切换 1 2 3 onSaveInstanceState ( ) 4 5 7 1 2 3 onRestoreInstanceState( )
Bundle
onRestoreInstanceState ( )
四种启动模式 launch mode standard singleTop singleTask singleInstance
10.Service
概念
本地服务 startService stopService
Service onCreate onStartCommand onDestroy
绑定服务 bindService(Intent,ServiceConnection)
unbindService(intent)
onCreate() onBind() onServiceConnected() onUnbind() onDestroy()
在onBind()函数中返回Binder对象,在ServiceConnection中通过onServiceConnected()方法得到服务返回的 Binder对象
onServiceDisconnected() 系统控制调用
11.ContentProvider的使用
概念:解决进程之间数据共享的问题,把自己应用中的数据(数据库、本地的文件)暴露给其他应用。
URI:统一资源标识符,其中URL是URI中特殊的一种,代表网络请求地址。
uri的规范: content://com.baidu.map/user
url: http://ip:端口号/项目名/资源名
UriMatcher:这个类是系统提供的帮助类,主要是用来匹配uri的
UriMatcher urimather=new UriMatcher(-1);
// urimather.addUri("authority","path",int code);
urimather.addUri("com.baidu.map","user",1);
String uri_str="content://com.baidumap.user";
Uri uri=Uri.parse(uri_str);
int code= urimather.match(uri);
ContentUris: 帮助类,拼接id到uri中或者截取uri中id的值
String uri_str="content://com.baidumap/user";
Uri uri=Uri.parse(uri_str);
Uri new_uri= ContentUris.withAppendedId(uri, 10); //content://com.baidumap/user/10
long id=ContentUris.parseId(new_uri); //10
如何实现自定义ContentProvider
1.定义类继承ContentProvider 实现六个方法
getType() //返回数据的Mime-type值 自定义的情况下 一般用不到该方法 不需要关注太多
onCreate() //实例化数据库获得SQLiteDatabase对象
delete()
insert()
query()
update()
2.在Manifest文件中配置
<provider
android:name="com.syy.demo.provider.MyProvider"
android:authorities="com.syy.demo.providers"
android:exported="true"
>
</proivder>
11.广播 BroadCastReceiver
广播的概念以及作用
静态广播:不管应用程序是否运行或者启动,广播都其作用,灵活性比较低
<receiver android:name="com.baidu.BoadcastReceiver">
<intent-filter>
<action android:name="com.baidu.MY_RECEIVER"/>
</intent-filter>
<receiver>
Intent intent=new Intent("com.baidu.MY_RECEIVER");
动态广播:必须要注册之后,广播才能生效
IntentFilter intentfilter=new IntentFilter();
intentFilter.setAction("com.baidu.MY_RECEIVER");
MyBroadCastReciver my=new MyBroadCastReceiver();
registerReceiver(my,intentfilter);
发送广播:sendBroadCastReceiver();
项目中用广播实现了什么功能
广播截取短信,广播监听手机信号强度,广播监听系统来电
开机自启动项目或者服务
即时通信 收到服务器发送的消息 发送广播给系统 通知显示信息
MP3音乐播放器 音乐播放完毕 发送广播 自动播放下一首
怎么实现的()
12. Intent
概念:
常用属性: action
data
catagory
flag
extra
显示Intent和隐式Intent的区别
返回桌面、打电话、拨号、地图、浏览器
13.PopupWindow(PopupMenu)
14.Notification(PedingIntent)
15. AIDL
能搭建出AIDL(可以参考)
16.I/0
1.SharedPreference
Editor commit()
2.访问本地文件系统 (非SDCRAD)
openFileInput()\openFileOutput
Context 的四种模式 private 、append 、world_readable 、world_writeable
访问sdcard
1.判断sdcard是否可用
2.路径、权限
3.I/O操作
3.数据库SQLite(db4o)
SQLiteOpenHelper 重写构造函数、onCreate、onUpgrade
SQLiteDatabase
数据库版本升级
获得数据库两种方法的区别
getReadableDatabase()
getWriteableDatabase()
4.Net
asset 区别
res/raw
res/xml
判断网络是否可用:
ConnectivityManager
connectivityManager=(ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info=connectivityManager.getActiveNetworkInfo();
info.isAvailable(); //网络是否可用
//判断wifi是否可用
NetworkInfo info1=connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
info1.isAvailable();
info1.isConnected(); //
//判断SIM网络是否可用
NetworkInfo info2=connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
info2.isAvailable();
info2.isConnected(); //
17、动画
补间动画 Tween Animation
帧间动画 Frame Animation
两种实现方式:
java
res/anim
AlphaAnimation
TranslateAnimation
RotateAnimation
ScaleAnimation
AnimationSet
setAnimation/startAnimation
18. ContentProvider 自定义 重写六个方法 getType() onCreate() CRUD
<provider android:name="路径"
authorities=“暴露给其他应该访问的URI”>
ContextResolver Activity 或者是 Context
content://com.twkj.demo/user/
URL Uniform Resource Lacator //浏览器中输入的地址
URI Uniform Resource Indetifier
19.MediaPalyer
setDataSource()
prepare()
start()
stop()
pause()
reset()
seekTo()
20.三种播放视频的方法
1、VideoView
2、SurfaceView+MediaPlayer
3、系统自带的播放器
21、Camera
1.系统自带的相机
2、SurfaceView SurfaceHolder
22、Handle机制
Thread+Handle
Looper Message MessageQueue
次线程中:
Looper.prepare();
{
h.sendMessage()
}
Looper.loop();
主UI
Handler{
handleMessage(){
}
}
23、WebView
loadURL
loadData
WebSettings
WebChromeClient
WebViewClient
点击超级链接在当前浏览器中打开
点击返回按钮,返回上一个页面而不是销毁当前的Activity
Android和JS的交互
24、移动互联
数据格式:
JSON和XML
解析数据的方式:
JSON: (JSONArray、JSONObject)、Gson
XML: SAX、Pull、DOM
SAX: SaxParserFactory SaxParser XMLReader
DefaultHandler{
startDocument()、startElement()
characters()、endElement、endDocument()
}
PULL: XMLPullFactory XMLPullParser (setInput()设置输入流以及编码方式)
判断事件类型
getEventType()
startDocument
startTag
endDocument
endTag
Text
getName()
getNextText()
getText()
nextText();
请求服务端的几种方式:
Socket
HttpClient Get/Post
get:
HttpClient hc=new DefalutHttpClient();
String msg=URLEncode.encoding("张三");
HttpGet get=new HttpGet("url?id=1&name="+msg+"&start=5&end=10");
HttpResponse res=hc.execute(get);
HttpEntity entity=res.getEntity();
res.getStateLine().getStateCode()
InputStream is=entity.getContent();
Post:
//get方式发送值到服务端是把值拼接在URL后面传递的 http协议Header中
//post方式发送值到服务端是把值放到Http协议的body体中
//构建传送给服务端的数据
List<NameValuePair> list=new ArrayList<NameVaulePair>();
NameValuePair bnvp=new BasicNameValuePair();
bnvp.put("name","key"); 发送给服务端的值和get方式不同
list.add(bnvp);
URLEncodedFormEntity uefe=new URLEncoderFormEntity(list);
HttpClient hc=new DefalutHttpClient();
String msg=URLEncode.encoding("张三");
String url=" 请求服务器的地址";
HttpPost post=new HttpPost("url?id=1&name="+msg+"&start=5&end=10");
post.setEntity(uefe); //设置Post发送的实体
HttpResponse res=hc.execute(post);
HttpEntity entity=res.getEntity();
res.getStateLine().getStateCode()
InputStream is=entity.getContent();
HttpUrlConnection
get方式:
URL url=new URL("请求服务端的地址");
HttpURLConnection conn=url.openConnection();
conn.setConnectTimeOut(3000);
conn.setReadTimeOut(3000);
InputStream is=conn.getInputStream()
conn.getResponseCode()==200
post方式:
URL url=new URL("请求服务端的地址");
HttpURLConnection conn=url.openConnection();
conn.setReuqestMethod("post");
conn.setdoInput(true);
conn.setdoOutput(true);
conn.setConnectTimeOut(3000);
conn.setReadTimeOut(3000);
conn.setUseCaches(false); //post方式一般设置不使用缓存
InputStream is=conn.getInputStream();
conn.getResponseCode()==200
public class Download extends AsyncTask<String,Integer,String>{
public void onPreExecute(){
}
public String doInBackground(String...){
publishProgress(Integer);
}
public void onUpdateProgress(Integer...){
}
public void onPostExecute(String str){
}
}