android实习期日常笔记(三)

1.Setting.Secure

PS:Secure system settings, containing system preferences that applications can read but are not allowed to write. These are for preferences that the user must explicitly modify through the system UI or specialized APIs for those values, not modified directly by applications.


2.BroadcastReciver 广播接收者


3.context

http://blog.csdn.net/qinjuning/article/details/7310620


4.intent和intentFileter


http://liuzhichao.com/p/506.html


5. android 4.4以后短信拦截。

无法拦截cancle Broadcast。


6.获本机联系人的手机号并匹配

  class ifNumAlreadyExist extends Thread{
    	 String interceptPhonenumber;
    	
    	ifNumAlreadyExist(String interceptPhonenumber){
    		this.interceptPhonenumber = interceptPhonenumber;
    	}
    	public void run(){
    		ifNumExist =ifNumAlreadyExisting(interceptPhonenumber);
    	}
    	
        private boolean ifNumAlreadyExisting(String interceptPhonenumber) {
    		Cursor cur = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);    
            //循环遍历    
            if (cur.moveToFirst()) {    
                int idColumn  = cur.getColumnIndex(ContactsContract.Contacts._ID);    
                    
                int displayNameColumn = cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);    
                do {    
                    //获得联系人的ID号    
                   String contactId = cur.getString(idColumn);    
                   //获得联系人姓名    
                   String disPlayName = cur.getString(displayNameColumn);    
                   //查看该联系人有多少个电话号码。如果没有这返回值为0    
                   int phoneCount = cur.getInt(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));    
                   if(phoneCount>0){    
                       //获得联系人的电话号码    
                       Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID+ " = " + contactId, null, null);    
                       if(phones.moveToFirst()){    
                           do{    
                               //遍历所有的电话号码    
                               String phoneNumber= phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));    
                               if(interceptPhonenumber.equals(phoneNumber)){
                            	   return true;
                               }
                            }while(phones.moveToNext());    
                       }    
                       
                   }    
            
                   } while (cur.moveToNext());    
            
            }
            return false;
    	}
    }

7.handler和多线程

首先在Activity中创建一个继承自Handler的匿名内部类以及这个类的一个对象

Private MainHandler mMainHandler = new MainHandler();

private class MainHandler extends Handler {

    public voidhandleMessage(android.os.Message msg) {

        switch (msg.what) {

        case MSG_MAIN_HANDLER_TEST:

            Log.d(TAG"MainHandler-->handleMessage-->thread id =" +     Thread.currentThread().getId());

            break;

        }

    }

 };

这样在Activity的其他地方就可以通过mMainHandler对象发送消息给Handler处理了

Message msg = mMainHandler.obtainMessage(MSG_MAIN_HANDLER_TEST);

        mMainHandler.sendMessage(msg);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值