读书人

如何获取收到的短信的中内容

发布时间: 2012-05-06 16:15:43 作者: rapoo

怎么获取收到的短信的中内容
我本来是想 弄个broadcast receiver 监听短信 然后发给一个service
public void onReceive(Context context, Intent intent) {
intent.setClass(context,SendMessage.class);
context.startService(intent);
}

但是不知道怎么在service中获得短信中的内容
下面是我乱写的
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
String smgBody = null;
Bundle bundle = new Bundle();
bundle=intent.getExtras();
smgBody=bundle.getString("sms_body");
Log.i(TAG,smgBody);
}


但是是错误的 这样获取不到短信的内容 请教高手 谢谢




[解决办法]
。。。可以直接在广播接受器那里写。。具体代码。。百度下不就有了吗

读书人网 >Android

热点推荐