1.到libs聚合SDK是聚合数据平台,为移动开发者提供的免费数据接口.使用前请先到聚合平台(http://www.juhe.cn/)注册,申请相关数据.
2.下载聚合数据SDK,将开发包里的smscaptcha_sdk_v_1_1.jar拷贝到libs根目录下,将libJuheSDK_v_1_0.so拷贝到libs\armeabi目录下,如图:
3.根据接口说明文档找到以下方法:
/** * * @param phone * phone number * @param callBack */ public void sendCaptcha(String phone,ResultCallBack callBack) /** * * @param phone * phone number * @param code * verify code * @param callBack */ public void commitCaptcha(String phone,String code,ResultCallBack callBack) /** * * @param phone * phone number * @param callBack */ public void getContentFriends(ResultCallBack callBack)
4.程序中调用方法
首先,在AnroidManifest.xml中添加权限
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.READ_CONTACTS" />
在application标签内部加入你申请的openid
<Meta-data android:name="JUHE_KEY" android:value="申请的openid" />
CommonFun.initialize(getApplicationContext());
导入相关包
import com.thinkland.smssdk.SMSSDK; import com.thinkland.smssdk.util.JsonCallBack;
//发送验证码 SMSCaptcha captcha = SMSCaptcha.getInstance(); captcha.sendCaptcha(phone,new ResultCallBack() { @Override public void onResult(int code,String reason,String result) { // TODO Auto-generated method stub } });
5.返回字段及相关错误码
public void sendCaptcha(String phone,ResultCallBack callBack)
返回字段:无
public void commitCaptcha(String phone,ResultCallBack callBack)
返回字段:无
public void getContentFriends(ResultCallBack callBack)
返回字段: