需求:
模拟短信支付功能。创建两个Activity,功能分别为支付首页和短信验证Activity。用户在支付首页点击支付按钮,使用startActivityForResult()方法打开一个新的Activity,在短信验证Activity中模拟输入短信验证码,并判断是否正确,使用setResult()方法将判断的结构回传,最后,在支付首页Activity中提示用户。模拟的短信验证码为“9527”。
运行效果图:
xml代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
to