问题描述
- 编写一个截获短消息的程序?
-
编写一个截获短消息的程序?又没有人用Android studio做出来过?
解决方案
http://www.cnblogs.com/GarfieldTom/archive/2012/08/25/2655609.html
解决方案二:
跟用什么开发工具没关系,就是接收广播
解决方案三:
你需要接受短信的广播、我这里有段代码你可以参考一下:
smsBroadcastReceiver = new SMSBroadcastReceiver();
IntentFilter intentFilter = new IntentFilter(SMS_RECEIVED_ACTION);
intentFilter.setPriority(Integer.MAX_VALUE);
// 注册广播
this.registerReceiver(smsBroadcastReceiver, intentFilter);
smsBroadcastReceiver
.setOnReceivedMessageListener(new SMSBroadcastReceiver.MessageListener() {
@Override
public void onReceived(String message) {
Pattern pattern = Pattern.compile("^.*([0-9]{4}).*$");
Matcher matcher = pattern.matcher(message);
if (matcher.find()) {
inputCodeEt.setText(matcher.group(1));
}
}
});
}
时间: 2024-11-25 21:35:57