Skip to content

Commit

Permalink
2017-7-31 14:53:43
Browse files Browse the repository at this point in the history
  • Loading branch information
hubeijiangcan committed Jul 31, 2017
1 parent 83b73bb commit e56b5b3
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 11 deletions.
10 changes: 9 additions & 1 deletion Summary/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,25 @@



<receiver android:name=".reciver.BootBrodCaseReciver">
<receiver android:name=".reciver.BootBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<!--<category android:name="android.intent.category.HOME"/>-->
</intent-filter>
</receiver>

<receiver android:name=".reciver.SmsBroadcastReceiver">
<intent-filter>
<!--接收短信的action -->
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ public JSONObject obtainJson(Object...objects){
/**
* Json提交
* @param params
*
*
*
* @param callBack
*/
public void post(JSONObject jsonObject,final ResponseHandler callBack){
Expand All @@ -148,7 +151,6 @@ public void onFailure(Call call, IOException e) {
fail(callBack,e);
}

@Override
public void onResponse(Call call, Response response) throws IOException {
if (response != null && response.isSuccessful()){
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.util.Log;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.mitbbs.summary.R;
import com.mitbbs.summary.base.BaseActivity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
/**获取联系人列表
* Created by jc on 2017/6/2.
*/
public class SelectContactActivity extends BaseActivity{
Expand All @@ -31,17 +33,43 @@ protected void bindViews() {

lv_contact = (ListView) findViewById(R.id.lv_contact);
data = selectContact();
Log.e("Tag",data.toString());
lv_contact.setAdapter(new SimpleAdapter(SelectContactActivity.this,data,R.layout.item_contact,new String[]{"name","number"},new int[]{R.id.tv_name,R.id.tv_num}));
}

private List<Map<String,String>> selectContact() {

ContentResolver resolver = getContentResolver();
//得到查询raw_contacts表的URI:raw_contacts:存放了contact_id
Uri uri = Uri.parse("content://com.android.contacts/raw_contacts");
Cursor cursor = resolver.query(uri,new String[]{"contact_id"},null,null,null);
while (cursor.moveToNext()){

Cursor cursor = resolver.query(uri, new String[]{"contact_id"}, null, null, null);
while(cursor.moveToNext()){
String contact_id = cursor.getString(0);

//根据contact_id查询data表
//得到查询data表的URI:data联系人信息的数据字段值
Uri dataUri = Uri.parse("content://com.android.contacts/data");

//关联查询data,mimetype表示mimetypes表中的mimetype字段
Cursor dataCursor = resolver.query(dataUri, new String[]{"mimetype","data1"}, "raw_contact_id=?", new String[]{contact_id}, null);
Map<String,String> map = new HashMap<String, String>();

while(dataCursor.moveToNext()){
String mimetype = dataCursor.getString(0);
String data1 = dataCursor.getString(1);

if("vnd.android.cursor.item/phone_v2".equals(mimetype)){
//电话号码
map.put("number", data1);

}else if("vnd.android.cursor.item/name".equals(mimetype)){
//姓名
map.put("name", data1);
}
}
data.add(map);

}
return null;
return data;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.mitbbs.summary.reciver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
* Created by jc on 2017/6/2.
*/
public class BootBroadcastReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Log.e("Summary","开机了");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import android.content.Intent;

/**
* Created by jc on 2017/6/2.
* Created by jc on 2017/6/6.
*/
public class BootBrodCaseReciver extends BroadcastReceiver{
public class SmsBroadcastReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public static TipsToast makeText(Context context,CharSequence text,int duration)
}


public static TipsToast makeText(Context context, int resId, int duration) throws Resources.NotFoundException {
public static TipsToast makeText(Context
context, int resId, int duration) throws Resources.NotFoundException {
return makeText(context, context.getResources().getText(resId), duration);
}

Expand Down

0 comments on commit e56b5b3

Please sign in to comment.