本文介绍了如何阅读新未来信息中的Android邮件内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能帮助我?
我想读一个新的传入短信的android的邮件正文,编程。
我试过的东西,但不返回任何内容:
I tried something but that doesn't return any contents:
Uri uri = Uri.parse("content://sms/inbox");
ContextWrapper context = null;
Cursor c = context.getContentResolver().query(uri, null, null ,null,null);
String body = null;
String number=null;
if(c.moveToFirst()) {
body = c.getString(c.getColumnIndexOrThrow("body")).toString();
number = c.getString(c.getColumnIndexOrThrow("address")).toString();
}
c.close();
是他们在我的code任何错误请任何人给我的答案,请完全是因为我浪费了一个月时间这个
Is their any error in my codePlease any one give me the answer please because totally i wasted one month for this
推荐答案
我已经贴在我的班级网站关于这方面的一些示例程序。下面是例子读短信为例这里是code片段。基本上,你可以注册一个广播接收器监听SMS_Receive,并检查了以下内容。
I have posted some sample programs about this on my class website.Here is the example Read SMS ExampleHere is a snippet of code. Basically your can register a broadcast receiver to listen for SMS_Receive and check out the following.
Intent intent = getIntent();
Bundle bundle = intent.getBundleExtra("mySMS");
if (bundle != null) {
Object[] pdus = (Object[])bundle.get("pdus");
SmsMessage sms = SmsMessage.createFromPdu((byte[])pdus[0]);
Log.i("mobile.cs.fsu.edu", "smsActivity : SMS is <" + sms.getMessageBody() +">");
//strip flag
String message = sms.getMessageBody();
while (message.contains("FLAG"))
message = message.replace("FLAG", "");
TextView tx = (TextView) findViewById(R.id.TextBox);
tx.setText(message);
} else
Log.i("mobile.cs.fsu.edu", "smsActivity : NULL SMS bundle");
这篇关于如何阅读新未来信息中的Android邮件内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!