當前位置:首頁 » 安卓系統 » android用戶登陸

android用戶登陸

發布時間: 2022-06-22 15:41:12

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億台。

熱點內容
安卓加速器怎麼關 發布:2025-05-15 11:38:16 瀏覽:463
密碼鎖壞了如何打開 發布:2025-05-15 11:30:19 瀏覽:837
怎樣增加共享文件夾連接數量 發布:2025-05-15 11:24:50 瀏覽:961
安卓如何關閉單應用音量 發布:2025-05-15 11:22:31 瀏覽:351
抖音電腦後台伺服器中斷 發布:2025-05-15 11:11:59 瀏覽:307
sql2008伺服器 發布:2025-05-15 11:03:27 瀏覽:306
我的世界pe伺服器創造 發布:2025-05-15 10:51:17 瀏覽:608
移動端打吃雞要什麼配置 發布:2025-05-15 10:48:16 瀏覽:756
我的世界哪五個伺服器被炸了 發布:2025-05-15 10:36:16 瀏覽:994
ehcache存儲對象 發布:2025-05-15 10:35:31 瀏覽:528