部分接口和类的学习

1、Handler的基本概念
   A Handler allows you to send and process Message and Runnable objects associated with a thread's MessageQueue.
Handler handler = new Handler();
handler.post(updateThread);//调用Handler的post方法,将要执行的线程对象条件到队列当中;
将要执行的操作写在线程对象的run方法中
Runable updateThread = new Runable();
{
  public run(){
    handler.postDelayed();
    postDelayed(Runable r,long uptimeMillis)
    Causes the Runnable to be added to the message queue ,to be run after the specified amount of time elapses.
  }
}
Activity 处在一个线程中,自己的处理放在另一个线程中。

 Handler updateBaHandler = new Handler(){
  // Message : Defines a message containing a description and arbitrary data object that can be sent to a Handler.
  //  arg1     arg1 and arg2 are lower-cost alternatives to using setData() if you only need to store a few integer values.
        public void handleMessage(Message msg){
            bar.setProgress(msg.arg1);
            updateBaHandler.post(updateThread);
        }
    };
    //线程类,该类使用匿名内部类的方式进行生命
    Runnable updateThread = new Runnable() {
        int  i = 0 ;
        public void run() {
            System.out.println("Begin Thread");
            //得到一个消息对象,Message类是有Andoroid操作系统提供
            i = i + 10;
            Message msg = updateBaHandler.obtainMessage();//得到message对象
           
            //将msg对象的arg1参数的值设置为i,用agr1和agr2系统优化
            msg.arg1 = i;
            try{
                Thread.sleep(1000);
            }catch(InterruptedException e){
                e.printStackTrace();
            }
           
            updateBaHandler.sendMessage(msg);
            if(i == 100){
                updateBaHandler.removeCallbacks(updateThread);
            }
            //handler.postDelayed(updateThread, 3000);
           
        }
    };

2、android.database.Cursor is a interface ,this interface provides random read-write access to the result set returned by a database query .
   Cursor implementations
   are not required  to be synchronized ;
3、android.context.ContextValues ,the class is used to stroe  a set of values that ContextResolver(内容解析器) can process
4、parcelable is a interface ,interface for classes whose instances can be written to and restored from a Parcel .Classes implementing
   the Parcelable interface must alseo have a static field called creator ,which is an object implementing the Parcelable.Creator interface;
5、android.util.Log API for sending log output .realistically ,there is also another buffer allocation and copy ,and even more pressure on the
   gc.That means that if your log message is filtered out,you might be doing significant work and incurring significant overhead .(做重大的工作和承担重大的开销)
6、HttpInterface for an HTTP client.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值