Hi In My在加载后单击登录按钮用户名和密码后,我需要清除用户名和密码。 并登录它正在移动到下一个活动但是,点击模拟器后退按钮对话框显示加载符号。 任何人都可以帮助我。
登录
login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog = ProgressDialog.show(Login.this, "",
"loading", true);
dialog.show();
isInternetPresent = cd.isConnectingToInternet();
if (!isInternetPresent) {
showAlertDialog(Login.this, "No Internet Connection",
"You don't have internet connection.", true);
return;
}
String username = usname.getText().toString();
String password = pword.getText().toString();
String name = user.get(SessionManager.KEY_USERNAME);
if (username.equals("")) {
Toast.makeText(Login.this, "ENTER USERNAME",
Toast.LENGTH_LONG).show();
}
if (password.equals("")) {
Toast.makeText(Login.this, "ENTER PASSWORD",
Toast.LENGTH_LONG).show();
}
else if (!CheckUsername(username) && !CheckPassword(password)){
Toast.makeText(Login.this, "ENTER VALID USERNAME & PASSWORD",
Toast.LENGTH_LONG).show();
}
else{
queryString = "username=" + username + "&password="
+ password ;
String usertype = DatabaseUtility.executeQueryPhp("usertype",queryString);
System.out.print(usertype);
if(usertype.equalsIgnoreCase("Admin user Found")){
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(Login.this, "Login Sucess",
Toast.LENGTH_LONG).show();
}
});
dialog.dismiss();
startActivity(new Intent(Login.this, Home.class));
}
else if(usertype.equalsIgnoreCase("Student User Found")){
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(Login.this, "Login Sucess",
Toast.LENGTH_LONG).show();
}
});
dialog.dismiss();
Intent i = new Intent(Login.this, StudentPortal.class);
i.putExtra("username",username);
startActivity(i);
}
else if(usertype.equalsIgnoreCase("Teacher user Found")){
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(Login.this, "Login Sucess",
Toast.LENGTH_LONG).show();
}
});
dialog.dismiss();
startActivity(new Intent(Login.this, Home.class));
finish();
}
else if(usertype.equalsIgnoreCase("No User Found")){
runOnUiThread(new Runnable() {
public void run() {
tv1.setText("InValid UserName and Password");
}
});
}
}
}
});
tv1.setText("");
}
答案 0 :(得分:0)
dialog = ProgressDialog.show(Login.this, "", "loading", true); dialog.show();
您正在显示进度对话框,我没有看到您在执行任何操作/ startActivity后将其解雇。
dialog.dismiss();
答案 1 :(得分:0)
在您调用startActivity
时,忽略对话框,将以下代码放在'startActivity'上
dialog.dismiss()
或者您可以通过自定义方法进行解散。
答案 2 :(得分:0)
你应该致电
dialog.dismiss();
开始新活动之前
答案 3 :(得分:0)
如果没有将登录活动保留在堆栈中并且禁止用户返回它,则应将其添加到您的活动映射中:LoginActivity" android:excludeFromRecents="true">
答案 4 :(得分:0)
如果您使用AsyncTask.
AsyncTask
点击onPreExecute()
显示Button
,onPostExecute(Result)
忽略该对话框,移至下一个活动,进行更改在用户界面中显示Toast ,并在doInBackground(Params...)
所有Dialog
调用