利用ContentResolver访问者获取手机短信信息
来源:互联网 发布:淘宝女装优质标签卖家 编辑:程序博客网 时间:2024/05/17 08:56
利用ContentResolver访问者获取手机短信信息
结果如下:
activity_message.xml类:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_message" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.example.android_25.MessageActivity"> <ListView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/lv_message" > </ListView></LinearLayout>
activity_xs.xml类
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_xs" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.example.android_25.XsActivity"><TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/tv_name" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/tv_telephone" /></LinearLayout>
MessageActivity类:
public class MessageActivity extends AppCompatActivity { private ListView lv_message; private ContentResolver cr; private ArrayList<Map<String, Object>> datalistView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_message); //获得短信的ID lv_message = (ListView) findViewById(R.id.lv_message); //得到访问者ContentResolver cr = getContentResolver(); //定义一个接收短信的集合 datalistView = new ArrayList<>(); Uri uri = Uri.parse("content://sms/"); Cursor cursor = cr.query(uri, null, null, null, null); while (cursor.moveToNext()) { String body = cursor.getString(cursor.getColumnIndex("body")); int address = cursor.getInt(cursor.getColumnIndex("address")); //将号码和短信内容放入Map集合中 Map<String, Object> map = new HashMap<>(); map.put("images", address+""); map.put("titles", body); datalistView.add(map); } SimpleAdapter adapter = new SimpleAdapter(this, datalistView, R.layout.activity_xs, new String[]{"images", "titles"}, new int[]{R.id.tv_name, R.id.tv_telephone}); lv_message.setAdapter(adapter); }}
0 0
- 利用ContentResolver访问者获取手机短信信息
- 利用ContentResolver内容访问者获取手机联系人信息
- 使用ContentResolver获取联系人信息
- 获取手机短信会话信息 Android
- android-内容访问者contentResolver
- Android-ContentResolver内容访问者
- ContentResolver(内容访问者)
- 通过ContentResolver获取手机中的联系人信息
- Android ContentResolver ContactsContract 获取手机联系人信息
- 如何获取手机短信和通话记录信息
- ContentResolver(内容访问者)访问通讯录
- android之ContentResolver内容访问者
- android内容访问者+获取联系人信息
- 利用iframe技巧获取访问者qq
- 利用iframe技巧获取访问者qq
- 获取手机短信
- Android中利用ContentResolver获取本地音乐和相片
- Android中利用ContentResolver获取本地音乐和相片
- 网络上长说的监听某个端口是什么意思
- faster-rcnn(matlab版)在windows平台上的配置
- ReentrantReadWriteLock读写锁的使用
- 环信SDK 头像、昵称、表情自定义和群聊设置的实现 一(附源码)
- JavaWeb从入门到精通(三)-servlet编程
- 利用ContentResolver访问者获取手机短信信息
- leetcode520: Detect Capital
- Javascript隐式转换
- android 自定义控件之ViewGroup生命周期执行步骤
- 方法的使用——打印日历
- [母函数 泰勒展开] BZOJ 3028 食物
- js入门
- 并查集详解
- php 命名空间