惯看花开花又谢,却怕缘起缘又灭…….成为你的护身符 shuangjian_wei@qq.com

android学习第一篇 基本概念

一。

   1.  Android 四大組件 Activity , Service  , BroadcastReceiver ,ContentProvider
  2.  多個Activity組成棧,當前Activity处于最顶层
  3.  setTheme(int resid)可以用来设置窗口风格

二。

  1.  Service一般运行在后台,不需与用户交互,没有界面

  2.  Service有自己的独立生命周期,通常为其他组件提供后台服务或者监控其他组件运行状态

三。

  1.  BroadcastReciver 广播消息接收器     类似事件监听器   区别是BroadcastReciver 监听的事件源是Android 应用中的其他组件

  2.  实现自己的BroadcastReceiver子类,  重写onReceive(Context context,Intent intent)方法即可  

四。

  1.  ContentProvider实现的是跨应用数据交换

  2.  实现自己的ContentProvider 需要实现抽象方法insert(Uri,ContentValues)       

                                   delete(Uri,ContentValues)        

                                                                             update(Uri,ContentValues,String ,String[])   

                                                                             query(Uri,String[],String,String[],String);

  3.  ContentResolver 用来访问数据

五。Intent   IntentFilter

  1.  Intent是Android应用不同组件之间通讯的媒介

  2.  启动一个Activity  调用Context的startActivity(Intent intent)         

     调用startActivityForResult(Intent intent,int requestCode)    

           intent 中封装了要启动的Activity信息       

  3.  启动一个Service   调用Context的startService(Intent intent)方法         

           调用bindService(Intent intent,ServiceConnection conn,int flags)  i

           ntent 中封装了要启动的Service信息

  4.  触发BroadcastReceiver  调用Context的sendBroadcast(Intent intent)                               

                                                        sendStickyBroadcast(Intent intent)                               

                                                        sendOrderedBroadcast(Intent intent,String receiverPermission)    

           三个函数的intent参数封装了药触发的BroadcastReceiver信息            

  5.  显式和隐式    

     显式Intent明确指明触发组件类名                     

           隐式只指定要启动或者触发的组件要满足的条件                                   

 

posted @ 2016-12-28 21:55  护身符  阅读(151)  评论(0编辑  收藏  举报
宝剑锋从磨砺出 梅花香自苦寒来!
联系我: shuangjian_wei@qq.com