android用户登陆
A. Android登录成功以后,在个人中心界面显示登录时的用户名图片2登陆成功后获得用户名和账号,怎
摘要 1、从布局中取得用户名和密码
B. Android登陆后如何判定是否登录 并且在已经登录的时候如何获取用户信息
给你详细讲一下。 比如系统有个登陆页面(login.jsp): name:_________ password:____________ (登陆按钮) 你按下登陆按钮,就根据name和password去数据库里面查,如果判断有此用户并且密码正确,就设置一个session的键对应的值,键名字自己取,统一即可,比如"userInfo",代码就是servlet的doPost里面 HttpSession session = request.getSession(); Hashtable userInfo = new Hashtable(); userInfo.setAttribute("userName", request.getParameter("userName"); userInfo.setAttribute("passWords", Util.toSecret( request.getParameter("passWords)); //密码最好加密 session.setAttribute("userInfo", userInfo); session是在一定时期(超时时间内)一直存在的,这段时间内你可以随时判断用户是否合法,否则就退回登陆页面。 在任何除了登陆页面以外的页面访问,只需判断有没有这个键值,没就到登陆页面,否则进正常页面。(最好写在servlet中,让servlet当页面控制器)代码如下: if ( session.getAttribute("userInfo")==null ) { response.sendRedirect(request.getServletContext.getPath() + "/login.jsp"); } else { request.getRequestDispatcher("/正常页面.jsp").forward(request,response); }
C. Android做用户登录的时候用什么方式记录用户的登录凭据
给你提几个方法: 1、存在android自带的小型数据库sqliteDataBase里面; 2、存在sharedpreference -- (Android轻型存储); 3、往SD卡写入一个文件,需要的时候读取出来用; 4、声明一个全局Application,将常量存进去(弊端:但程序退出则无法保存);
D. android应用程序中如何判断用户的登录状态
这里主要是用户名与密码的判断:
先用sharedpreferences方式存储数据,包含用户名和密码:username,password
然后在登录的时候进行判断:代码如下:
java">Stringname=et_username.getText().toString();
Stringpassword=et_password.getText().toString();
if(name.length()<=0&&password.length()<=0){
Toast.makeText(LoginActivity.this,"用户名或密码为空",0).show();
}elseif(name.length()<=0){
Toast.makeText(LoginActivity.this,"用户名不能为空",0).show();
}elseif(password.length()<=0){
Toast.makeText(LoginActivity.this,"密码不能为空",0).show();
}elseif(name!=null&&password!=null){
//获取存储的数据
SharedPreferencessp=getSharedPreferences("config",MODE_PRIVATE);
Stringsavename=sp.getString("username","");
intsavepassword=sp.getInt("password",0);
//判断用户名与密码是否和保存的数据一致,进行提醒或者登录
if(savename.equals(name)&&savepassword==Integer.parseInt(password)){
//实现界面的跳转
Intentintent=newIntent(LoginActivity.this,HomeActivity.class);
startActivity(intent);
//关闭当前界面
finish();
}else{
Toast.makeText(LoginActivity.this,"用户名或密码错误",0).show();
}
扩展:其中判断用户名或密码是否为空时还可以使用name.isEmpty()判断是否为空,但是这个方法好像在JDK1.5以下版本是不能用的
E. 为什么微信登录查看显示有Android设备登陆这是怎么回事呀
摘要 因为现在手机有两种系统,一个是苹果的系统,另一个是安卓系统。如果一旦你是苹果手机出现这种题型的,有可能是您的微信被Android用户登录过。
F. 如何使用Android Studio开发用户登录界面
用户登陆界面很简单
基本构成:
两个EditText,分别用于输入用户名和密码
一个Button,登陆按钮
好看的话再多两个图标,分别放在用户名和密码那两个EditText前面
再多就是还有一个找回密码的功能,一个TextView就行
G. 怎样在Android 设备登陆
Android设备登录就是用安卓系统的手机或电脑登录就是了,Android开发中Android设备如何通过网络进行远程操作。首先需要把Android设备连接到电脑上,先要打开tcpip连接方式。
H. android作业创建用户登陆和密码
布局文件:
<RelativeLayoutxmlns: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"
android:background="#efefef"
tools:context="cn.teachcourse.activity.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentTop="true"
android:background="#2088c2"
android:orientation="horizontal"
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:gravity="center_vertical"
android:text="登录界面"
android:textSize="22sp"
android:layout_gravity="center_vertical"
android:textColor="#FFFFFF"/>
</LinearLayout>
<!--输入用户名框-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/center_point"
android:background="#FFFFFF"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:drawableLeft="@drawable/user_login_icon"/>
<EditText
android:id="@+id/user_name_ET"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:hint="@string/username_hint"/>
</LinearLayout>
<!--输入密码框-->
<LinearLayout
android:id="@+id/pass_word_ll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/center_point"
android:background="#FFFFFF"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:drawableLeft="@drawable/user_login_lock"/>
<EditText
android:id="@+id/pass_word_ET"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:hint="@string/password_hint"
android:inputType="textPassword"/>
</LinearLayout>
<Button
android:id="@+id/login_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/pass_word_ll"
android:layout_margin="10dp"
android:background="@drawable/blue_bg"
android:text="@string/login_str"
android:textColor="#FFFFFF"/>
<View
android:id="@+id/center_point"
android:layout_width="1dp"
android:layout_height="1dp"
android:layout_centerInParent="true"/>
</RelativeLayout>
实现代码:
packagecn.teachcourse.activity;
importjava.util.regex.Matcher;
importjava.util.regex.Pattern;
importcn.teachcourse.common.BaseActivity;
importcn.teachcourse.utils.SharedPreferenceUtil;
importandroid.app.Activity;
importandroid.content.Intent;
importandroid.os.Bundle;
importandroid.text.TextUtils;
importandroid.view.View;
importandroid.view.View.OnClickListener;
importandroid.widget.Button;
importandroid.widget.EditText;
importandroid.widget.Toast;
/**
*@authorTeachCourse博客保存数据的的方法有:
*1、网络存储
*2、数据库sqlite存储
*3、SharedPreferences本地化存储
*4、File文件存储
*四种存储数据的方法,对应的Demo:
*NetworkDemo、SQLiteDemo、SharedPreferencesDemo和FileDemo
*
*/
{
privateEditTextmUserName_ET,mPassword_ET;
privateButtonmLogin_btn;
privateStringusername;
privateStringpassword;
@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
//activity_main编辑一个注册登录界面
setContentView(R.layout.activity_main);
SharedPreferenceUtil.initPreference(this);
initView();
}
@Override
protectedvoidonResume(){
//检查SharedPreferences文件中是否保存有用户名和密码
super.onResume();
StringusernameStr=SharedPreferenceUtil.getString("username",null);
StringpasswordStr=SharedPreferenceUtil.getString("password",null);
if(!TextUtils.isEmpty(usernameStr)){
mUserName_ET.setText(usernameStr);
}elseif(!TextUtils.isEmpty(passwordStr)){
mPassword_ET.setText(passwordStr);
}
}
privatevoidinitView(){
mLogin_btn=(Button)findViewById(R.id.login_btn);
mUserName_ET=(EditText)findViewById(R.id.user_name_ET);
mPassword_ET=(EditText)findViewById(R.id.pass_word_ET);
mLogin_btn.setOnClickListener(this);
}
@Override
publicvoidonClick(Viewv){
switch(v.getId()){
caseR.id.login_btn:
login();
break;
}
}
privatevoidlogin(){
username=mUserName_ET.getText().toString().trim();
password=mPassword_ET.getText().toString().trim();
//这里只验证格式是否合法,不验证用户名和密码的正确性,SharedPreferences将数据存储到本地
if(checkPhone(username)&&checkNotNull(password)){
SharedPreferenceUtil.putString("username",username);
SharedPreferenceUtil.putString("password",password);
toSecondActivity();
}
}
privatevoidtoSecondActivity(){
Intentintent=newIntent(this,SecondActivity.class);
Bundlebundle=newBundle();
bundle.putString("username",username);
bundle.putString("password",password);
intent.putExtras(bundle);
startActivity(intent);
MainActivity.this.finish();
}
/**
*@paramvalue需要验证的用户名
*@return
*/
privatebooleancheckNotNull(Stringvalue){
if(!TextUtils.isEmpty(value)){
if(value.length()<6){
Toast.makeText(this,"密码填写不合法!",Toast.LENGTH_LONG).show();//号码填写不正确
returnfalse;
}else{
returntrue;
}
}else{
Toast.makeText(this,"密码不能为空",Toast.LENGTH_LONG).show();
returnfalse;
}
}
/**
*@paramphone需要验证的手机号码
*@return
*/
privatebooleancheckPhone(Stringphone){
if(!TextUtils.isEmpty(phone)){
if(ismobileNO(phone)){
returntrue;
}else{
Toast.makeText(this,"号码填写不正确",Toast.LENGTH_LONG).show();//号码填写不正确
returnfalse;
}
}else{
Toast.makeText(this,"号码不能为空",Toast.LENGTH_LONG).show();//不能为空
returnfalse;
}
}
/**
*手机号码的验证,严格验证
*
*@param/mobiles要验证的手机号码
*@return
*/
publicstaticbooleanismobileNO(Stringmobiles){
if(TextUtils.isEmpty(mobiles)){
returnfalse;
}
Patternp=Pattern
.compile("^((13[0-9])|(14[5,7])|(15[^4,\D])|(17[0,6,7,8])|(18[0-9]))\d{8}$");
Matcherm=p.matcher(mobiles);
returnm.matches();
}
}
效果图:
I. Android手机客户端开发中,如何实现用户登录
这是通过app与服务器通信实现的,android客户端把信息发送到服务器,服务器判断并反馈给android客户端
J. 怎样登陆Android 设备什么是Android 设备
Android就是安卓系统设备;可以直接输入自己的手机号进行登陆。
安卓(Android)是一种基于Linux内核(不包含GNU组件)的自由及开放源代码的操作系统。主要使用于移动设备,如智能手机和平板电脑,由美国Google公司和开放手机联盟领导及开发。Android操作系统最初由Andy Rubin开发,主要支持手机。
2005年8月由Google收购注资。2007年11月,Google与84家硬件制造商、软件开发商及电信营运商组建开放手机联盟共同研发改良Android系统。随后Google以Apache开源许可证的授权方式,发布了Android的源代码。第一部Android智能手机发布于2008年10月。
Android逐渐扩展到平板电脑及其他领域上,如电视、数码相机、游戏机、智能手表等。2011年第一季度,Android在全球的市场份额首次超过塞班系统,跃居全球第一。
2013年的第四季度,Android平台手机的全球市场份额已经达到78.1%。2013年09月24日谷歌开发的操作系统Android在迎来了5岁生日,全世界采用这款系统的设备数量已经达到10亿台。