本文介绍了我怎样才能读取收件箱中Android手机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过安卓application.Any任何一个读取的短信收件箱的Android手机知道
i want read Sms inbox in android mobile via android application.Any one know this
推荐答案
使用内容解析,
Uri mSmsinboxQueryUri = Uri.parse("content://sms");
Cursor cursor1 = getContentResolver().query(
mSmsinboxQueryUri,
new String[] { "_id", "thread_id", "address", "person", "date",
"body", "type" }, null, null, null);
startManagingCursor(cursor1);
String[] columns = new String[] { "address", "person", "date", "body",
"type" };
if (cursor1.getCount() > 0) {
String count = Integer.toString(cursor1.getCount());
Log.e("Count",count);
while (cursor1.moveToNext()) {
out.write("<message>");
String address = cursor1.getString(cursor1
.getColumnIndex(columns[0]));
String name = cursor1.getString(cursor1
.getColumnIndex(columns[1]));
String date = cursor1.getString(cursor1
.getColumnIndex(columns[2]));
String msg = cursor1.getString(cursor1
.getColumnIndex(columns[3]));
String type = cursor1.getString(cursor1
.getColumnIndex(columns[4]));
}
}
这将同时读取收件箱和发items.If你想读的收件箱或单独发送的项目,那么你的内容解析指定它。
This will read both inbox and sent items.If you want to read the inbox or sent items alone then you specify it in content resolver.
Uri mSmsinboxQueryUri = Uri.parse("content://sms/inbox");
Uri mSmsinboxQueryUri = Uri.parse("content://sms/sent");
有关读你的短信,你必须在AndroidManifest.xml中添加使用,许可,
For reading your SMS you must add uses-permission in androidmanifest.xml,
<uses-permission android:name="android.permission.READ_SMS" />
这篇关于我怎样才能读取收件箱中Android手机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!