类似于android短信校验码的demo
来源:互联网 发布:tcp常用端口 编辑:程序博客网 时间:2024/05/04 15:36
该demo主要实现了类似于银行支付短信校验的功能,30s后可重新进行校验,具体功能没实现,只是用Handler和Timer,TimerTask写了个简单的demo,具体如下:
1、Layout布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/icode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/obtain_vcode"
tools:context=".MainActivity" />
</RelativeLayout>
2、MainActivity代码
package com.jon.mmsverfiy;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity implements OnClickListener {
private Button getVerfiyCode = null;
private Timer timer = null;
private Handler handler = new Handler() {
public void handleMessage(Message msg) {
if (msg.what > 0) {
// getVerfiyCode.setEnabled(false);
getVerfiyCode.setText(msg.what + "s后可以重新进行校验");
} else {
getVerfiyCode.setEnabled(true);
getVerfiyCode.setText(R.string.obtain_vcode);
timer.cancel();
}
};
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViews();
setListens();
}
private void setListens() {
getVerfiyCode.setOnClickListener(this);
}
private void findViews() {
getVerfiyCode = (Button) findViewById(R.id.icode);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.icode:
getVerfiyCode.setEnabled(false);
timer = new Timer();
timer.schedule(new TimerTask() {
int timeCount = 30;
@Override
public void run() {
handler.sendEmptyMessage(timeCount);
timeCount--;
}
}, 200, 1000);
break;
default:
break;
}
}
}
- 类似于android短信校验码的demo
- 类似于黑名单的短信拦截
- java短信生成6位数的校验码
- android 短信助手demo
- Android:发短信Demo
- android短信demo
- 类似于微信通讯录的界面Demo
- 类似于微信通讯录的界面Demo
- android最简单的发送文本短信的demo
- android实现发送短信demo
- Android demo之发送短信
- Android 实现发送短信demo
- android类似于Jfreechart的图表
- 类似于微信发语音Demo
- 【iPhone Demo】地图自定义大头针如何利用Android TabHost+ActivityGroup+Broadcast实现类似于iPhone的底部菜单
- Android中通过短信获取手机的消费情况的Demo
- 实现短信接口发送短信的小demo
- Android类似于滚动的通知栏实现
- Example for lua table
- Product文本格式说明
- 机器学习问题方法总结
- ASP.NET 删除提示
- unity 内置 shader 源码
- 类似于android短信校验码的demo
- 二叉树层次遍历与递归释放
- Android中程序与Service交互的方式——综述
- mysql存储过程使用CURSOR操作多列数据实用案例
- 获取当前应用的相对路径
- DbGridToExcel(Delphi)
- 设计模式(九)外观模式Facade(结构型)
- javaScript的性能优化
- Activity的四种launchMode 详细分析