重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
package com.pzq.test.zhuanpan4; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.Handler; import android.telephony.SmsMessage; import android.text.TextUtils; import android.util.Log; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Created by asus on 2016/6/26. */ public class SMSUtils { private BroadcastReceiver smsReceiver, codeReceiver; private IntentFilter filter, mIntentFilter; private Handler handler; private String strContent; private String patternCoder = "(? * * registerReceiver(); u = new SMSUtils(MainActivity.this); * private void registerReceiver() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(SMSUtils.MSMCode_CHANGE_BROADCAST); registerReceiver(new SMSBroadcastReceiver(), intentFilter); } class SMSBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction() == SMSUtils.MSMCode_CHANGE_BROADCAST) { Bundle bundle = intent.getExtras(); smScode = bundle.getString("code"); Log.d("mainpzqtest....", "mBroadcastReceiver...." + smScode); et.setText(smScode); } } }; * * */ }