使用第三方向发送手机短信Doem
来源:互联网 发布:淘宝的返利机器人 编辑:程序博客网 时间:2024/06/06 10:48
在Android studio 工程配置
在工程libs 导入MobCommons.jar,MobTools.jar,SMSSDK-2.0.1.aar,SMSSDKGUI-2.0.1.aar
在工程build.gradle配置
//<version> SMSSDK 版本号dependencies {
....
compile name:'SMSSDK-<version>',ext:'aar'
compile name:'SMSSDKGUI-<version>',ext:'aar'
}
/放aar的目录地址
repositories{
flatDir{
dirs 'libs'
}
}
在AndroidManifest.xml中配置权限
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
在application中添加
<activity
android:name="com.mob.tools.MobUIShell"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="stateHidden|adjustResize"/>
定义一个初始化的类
SMSSDK.initSDK(this,"key","Secret");key:您的appkeysecret:您的appsecret
view布局
获取手机号第一个activity 视图布局
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/zhuce_im_fanhui" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/ic_collection_pre_normal" android:layout_marginTop="10dp"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="手机号注册" android:layout_centerHorizontal="true" android:textSize="30sp" android:textColor="#000000" android:layout_marginTop="10dp"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="登录" android:textSize="20dp" android:layout_alignParentRight="true" android:layout_marginTop="10dp" android:layout_marginRight="10dp"/> <TextView android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginTop="60dp" android:background="#C0C0C0"/> <LinearLayout android:layout_width="240dp" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_centerHorizontal="true" android:layout_marginTop="90dp"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="+86" android:layout_marginLeft="30dp" android:textSize="25sp" android:textColor="#000000"/> <EditText android:id="@+id/zhuce_phone" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="请输入手机号" android:background="@null"/> </LinearLayout> <Button android:id="@+id/zhuce_bu_next" android:layout_width="150dp" android:layout_height="wrap_content" android:text="获取验证码" android:layout_marginTop="200dp" android:layout_centerHorizontal="true" android:textSize="25sp"/></RelativeLayout>
第二个activity中代码,这样显示的自己定义的布局
SMSSDK.getVerificationCode("86",phone);EventHandler eh=new EventHandler(){ @Override public void afterEvent(int event, int result, Object data) { if (result == SMSSDK.RESULT_COMPLETE) { //回调完成 if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) { //提交验证码成功 }else if (event == SMSSDK.EVENT_GET_VERIFICATION_CODE){ //获取验证码成功 }else if (event ==SMSSDK.EVENT_GET_SUPPORTED_COUNTRIES){ //返回支持发送验证码的国家列表 } }else{ ((Throwable)data).printStackTrace(); } }};SMSSDK.registerEventHandler(eh); //注册短信回调第二个activity 的xml布局
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_margin="5dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/pwd_back" android:src="@mipmap/ic_collection_pre_normal"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="手机号注册" android:layout_centerHorizontal="true" android:textSize="25sp"/> <TextView android:layout_width="match_parent" android:layout_height="1dp" android:background="#C0C0C0" android:layout_marginTop="35dp"/> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginTop="120dp" android:layout_centerHorizontal="true"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="已向手机"/> <TextView android:id="@+id/zhaoce_two_tv_denglu" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="********"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="发送验证码"/> </LinearLayout> <LinearLayout android:layout_width="300dp" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="200dp" android:orientation="horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/ic_tip_code" /> <EditText android:id="@+id/zhaoce_two_ed_yanzheng" android:layout_width="150dp" android:layout_height="wrap_content" android:hint="请输入验证码" android:layout_below="@+id/denglu_image01" android:layout_centerHorizontal="true" android:background="@null" android:layout_marginLeft="10dp"/> <TextView android:id="@+id/zhaohui_tv_text02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="开始倒计时"/> </LinearLayout> <TextView android:layout_width="300dp" android:layout_height="1dp" android:background="#C0C0C0" android:layout_marginTop="220dp" android:layout_centerHorizontal="true"/> <LinearLayout android:layout_width="300dp" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="240dp" android:orientation="horizontal"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@mipmap/ic_tip_pwd" /> <EditText android:id="@+id/zhaoce_two_ed_pwd" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="请设置密码(6-20英文或数字)" android:layout_below="@+id/denglu_image01" android:layout_centerHorizontal="true" android:background="@null" android:layout_marginLeft="10dp"/> </LinearLayout> <TextView android:layout_width="300dp" android:layout_height="1dp" android:background="#C0C0C0" android:layout_marginTop="260dp" android:layout_centerHorizontal="true"/> <Button android:id="@+id/zhaoce_two_bu_denglu" android:layout_width="120dp" android:layout_height="wrap_content" android:text="登录" android:layout_marginTop="300dp" android:layout_centerHorizontal="true"/></RelativeLayout>
- 使用第三方向发送手机短信Doem
- 使用J2ME发送手机短信
- 手机短信发送
- 使用WMA发送手机短信的详细说明
- 使用Qt Mobility实现手机短信的发送功能
- linux 下使用短信 api 给自己发送手机短信
- C# 使用SMS接口实现手机短信发送功能
- 通过PC发送手机短信
- C#发送手机短信
- 通过at发送手机短信
- 超级终端发送手机短信
- php 发送手机短信
- 简单手机短信发送软件
- 手机短信发送简单讲义
- JAVA发送手机短信
- java发送手机短信
- JAVA发送手机短信
- java发送手机短信
- 使用Retrofit踩到的坑(持续更新)
- 写一个死锁例子,及解决死锁
- ubuntu配置SSH远程连接
- Source Insight使用及快捷键
- Java学习路线(转载)
- 使用第三方向发送手机短信Doem
- gearman 入门使用笔记
- Docker学习之路
- LINUX中设备的访问 软硬链接 find命令
- Android 蓝牙自动匹配PIN码跳过用户交互
- 编程必备的23种设计模式
- Mybatis的ResultMap的使用
- Mysql 下载,安装、配置与使用
- Android 使用腾讯X5 Webview浏览器拍照或从相册上传图片