首先在布局中增添两个按钮,一个是获取短信验证码,一个是进入联系人界面
在依赖中增添两个。
compile name: 'SMSSDK-3.0.0', ext: 'aar
compile name: 'SMSSDKGUI-3.0.0', ext: 'aar'
清单文件
两个点击事件
package com.bwie.smssdk;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import java.util.HashMap;
import cn.smssdk.EventHandler;
import cn.smssdk.SMSSDK;
import cn.smssdk.gui.ContactsPage;
import cn.smssdk.gui.RegisterPage;
public class MainActivity extends AppCompatActivity {
private String phoneNumber = "";
private Button btn1;
private Button btn2;
private EditText et_num;
private EditText et_phone;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void register(View view) {
RegisterPage registerPage = new RegisterPage();
registerPage.setRegisterCallback(new EventHandler() {
public void afterEvent(int event, int result, Object data) {
// 解析注册结果
if (result == SMSSDK.RESULT_COMPLETE) {
@SuppressWarnings("unchecked") HashMap
phoneMap = (HashMap
) data;
String country = (String) phoneMap.get("country");
String phone = (String) phoneMap.get("phone");
}
}
});
registerPage.show(MainActivity.this);
}
public void friends(View view) {
// 打开通信录好友列表页面
ContactsPage contactsPage = new ContactsPage();
contactsPage.show(this);
}
}