启用从Android手机检索收件箱短信

时间:2012-09-08 06:49:23

标签: android sms inbox

ContentResolver cr = this.getContentResolver();
Cursor cursor = cr.query(Uri.parse("content://sms/inbox"), null, null,null, null);
cursor.moveToFirst();

if (cursor.getCount() > 0) {
    for (int j = 0; j < cursor.getCount(); j++) {
        String text = cursor.getString(
        cursor.getColumnIndexOrThrow("body")).toString();
        Log.d("sms", text);
        cursor.moveToNext();
    }
} else
    Log.d("no", "not working");
}

我还在androidmanifest.xml文件中给予了权限<uses-permission android:name="android.permission.READ_SMS"/>,它显示没有工作

0 个答案:

没有答案