首先,需要一个电话号码,目前很多账户都是将账户名设置成手机号,然后点击按钮获取手机验证码。
其次,你需要后台给你手机短信的验证接口,各个公司用的不一样,这个身为前端,不需要你来考虑,你只要让你后台给你写好接口,你直接调用就好了。
activity_login.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="60dp" android:layout_marginTop="20dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:gravity="center" android:orientation="horizontal"> <EditText android:id="@+id/mobile_login" android:layout_width="match_parent" android:layout_height="40dp" android:layout_marginLeft="10dp" android:hint="请输入您的手机号" android:textSize="16sp" android:background="@null" android:inputType="number" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="50dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginTop="15dp" android:gravity="center" android:orientation="horizontal"> <EditText android:id="@+id/yanzhengma" android:layout_width="0dp" android:layout_height="40dp" android:layout_weight="4" android:background="@null" android:layout_marginLeft="10dp" android:hint="请输入验证码" android:textSize="16sp" android:inputType="number" /> <Button android:id="@+id/getyanzhengma1" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1.9" android:textSize="13sp" android:gravity="center" android:text="获取验证码" android:layout_gravity="center" /> </LinearLayout> <Button android:id="@+id/login_btn" android:layout_width="match_parent" android:layout_height="40dp" android:layout_marginTop="20dp" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:text="登录" android:textSize="16sp" /> </LinearLayout>
本文名称:Android开发中通过手机号+短信验证码登录的实例代码-创新互联
文章来源:https://www.cdcxhl.com/article24/dsdcce.html
成都网站建设公司_创新互联,为您提供自适应网站、定制开发、电子商务、品牌网站制作、网站设计公司、网站建设
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联