Android 开发第一步 短信验证码登录

本文介绍了Android开发中短信验证码登录的常见实践,强调了其在用户信息安全方面的优势。开发者需要用户手机号,然后调用后台提供的短信验证接口。文中提到使用xutils进行网络请求,并简单提到了布局文件activity_login.xml的设计。
摘要由CSDN通过智能技术生成

目前的安卓开发中,常规的用户名+密码的登录方式已渐渐被账户+短信验证码替换掉。这主要是出于对用户信息安全的保证。现在和大家分享下关于短信验证码的使用。
首先,需要一个电话号码,目前很多账户都是将账户名设置成手机号,然后点击按钮获取手机验证码。
其次,你需要后台给你手机短信的验证接口,各个公司用的不一样,这个身为前端,不需要你来考虑,你只要让你后台给你写好接口,你直接调用就好了。
最后,讲一下操作的请求方式,我这里通过使用xutils进行请求,所以你需要先在你的项目中导入xutils项目包。

这里是具体的操作。


activity_login.xml
布局文件

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"
            
评论 18
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值