今天博主带给小伙伴们一个小功能,就是利用广播接收器实现自动填充短信验证码,话不多说,我们先看看如何去实现这个小功能。
首先我们需要新建一个名为SMSBroadcastReceiver的广播接收器,代码如下:
public class SMSBroadcastReceiver extends BroadcastReceiver {
private static MessageListener mMessageListener;
public SMSBroadcastReceiver(
BroadcastReceiver不仅可以接收系统广播,也可接收自定义的广播
1.定义一个广播接收器
代码如下:
public class MyReceiver extends BroadcastReceiver
{
public MyReceiver()
{
Log.i(TAG,”MyReceiver”);
}
//可用Intent的getAction()区分接