嗨,我正在尝试使用排球库创建登录页面。当我运行应用程序,输入所需的凭据,最后点击登录按钮时,我的logcat显示此错误:
我不知道是什么导致了这个错误,这是我的登录活动:
public class LoginActivity extends Activity {
private static final String TAG = LoginActivity.class.getSimpleName();
private Button btnLogin;
private EditText inputUsername;
private EditText inputPassword;
private ProgressDialog pDialog;
private SessionManager session;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
inputUsername = (EditText) findViewById(R.id.username);
inputPassword = (EditText) findViewById(R.id.password);
btnLogin = (Button) findViewById(R.id.btnLogin);
// Progress dialog
pDialog = new ProgressDialog(this);
pDialog.setCancelable(false);
// Session manager
session = new SessionManager(getApplicationContext());
// Check if user is already logged in or not
if (session.isLoggedIn()) {
// User is already logged in. Take him to main activity
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
// Login button Click Event
btnLogin.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
String username = inputUsername.getText().toString();
String password = inputPassword.getText().toString();
// Check for empty data in the form
if (username.trim().length() > 0 && password.trim().length() > 0) {
// login user
checkLogin(username, password);
} else {
// Prompt user to enter credentials
Toast.makeText(getApplicationContext(),
"Please enter the credentials!", Toast.LENGTH_LONG)
.show();
}
}
});
}
private void checkLogin(final String username, final String password) {
// Tag used to cancel the request
String tag_string_req = "req_login";
pDialog.setMessage("Logging in ...");
showDialog();
StringRequest strReq = new StringRequest(Method.POST,
AppConfig.URL_REGISTER, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, "Login Response: " + response.toString());
hideDialog();
try {
JSONObject jObj = new JSONObject(response);
boolean error = jObj.getBoolean("error");
// Check for error node in json
if (!error) {
// user successfully logged in
// Create login session
session.setLogin(true);
// Launch main activity
Intent intent = new Intent(LoginActivity.this,
MainActivity.class);
startActivity(intent);
finish();
} else {
// Error in login. Get the error message
String errorMsg = jObj.getString("error_msg");
Toast.makeText(getApplicationContext(),
errorMsg, Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
// JSON error
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(TAG, "Login Error: " + error.getMessage());
Toast.makeText(getApplicationContext(),
error.getMessage(), Toast.LENGTH_LONG).show();
hideDialog();
}
}) {
@Override
protected Map<String, String> getParams() {
// Posting parameters to login url
Map<String, String> params = new HashMap<String, String>();
params.put("tag", "login");
params.put("username", username);
params.put("password", password);
return params;
}
};
// Adding request to request queue
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}
private void showDialog() {
if (!pDialog.isShowing())
pDialog.show();
}
private void hideDialog() {
if (pDialog.isShowing())
pDialog.dismiss();
}}
请协助我。或者帮我找到一种更简单的方法来使用JSON和MYSQL数据库登录。谢谢
以下是我的AppController类:
public class AppController extends Application {
public static final String TAG = AppController.class.getSimpleName();
private RequestQueue mRequestQueue;
private static AppController mInstance;
@Override
public void onCreate() {
super.onCreate();
mInstance = this;
}
public static synchronized AppController getInstance() {
return mInstance;
}
public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(getApplicationContext());
}
return mRequestQueue;
}
public <T> void addToRequestQueue(Request<T> req, String tag) {
req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
getRequestQueue().add(req);
}
public <T> void addToRequestQueue(Request<T> req) {
req.setTag(TAG);
getRequestQueue().add(req);
}
public void cancelPendingRequests(Object tag) {
if (mRequestQueue != null) {
mRequestQueue.cancelAll(tag);
}
}}
此代码中的getInstance()方法
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
可能会给你空。
可以 u 开机自检的 AppCnotroller 类
就我而言,我将本地网址更改为在线
URL_REGISTER = "http://192.168.1.1/Register.php";
到
URL_REGISTER = "http://Webserver/Register.php"
不知道为什么这对我有效,哈哈
问题内容: com.android.volley.NoConnectionError:java.net.ProtocolException:未知方法“ PATCH”;必须是[OPTIONS,GET,HEAD,POST,PUT,DELETE,TRACE]中的一种 问题答案: 您确定使用的Volley Library版本正确吗?我刚刚在Lollipop中尝试了您的代码,它工作正常。如果您将Volley
编辑:我发现了一个类似的问题,专门针对Facebook的登录。我正在使用电子邮件认证,但问题/解决方案可能是相同的。 userinfo={nsunderlyingerror=0x14704d4b0{Error domain=firauthinternalerrordomain code=3“(null)”userinfo={firautherroruserinfoderializedrespons
我已经创建了一个登录名。html页面和登录名。php脚本。在脚本中,它将首先获得我们输入的用户名和密码,然后使用数据库检查用户名或密码是否存在,如果用户有效,则它将检查他的部门id,并使用部门权限打开他们的页面,但问题是无论他们的部门是什么,都会一直打开管理页面。请帮我做这件事。 这是我的login.html代码 登录。php脚本
我试图了解Spotify的登录/授权流程。我遵循一个教程,最终得到了这段代码。当我尝试登录时,会出现以下错误:-canOpenURL:URL失败:“spotify操作:/”-错误:“(null)” 我查看了回购协议,发现我需要将spotify action和spotify添加到信息中。在LSApplicationQueriesSchemes下注册。然而,在这样做后,我仍然得到上述错误。
我使用cakephp2.1和我在UsersController中使用登录操作如下。 和登录名。ctp代码如下。 当使用电子邮件和密码提交表单时,用户无法登录,因此显示错误“无效电子邮件或密码,请重试”。就连我都把这美元给递了-
我目前正在创建一个Symfony3应用程序,我无法使我的登录表单工作;我遵循以下步骤: http://symfony.com/doc/current/cookbook/security/form_login_setup.html http://symfony.com/doc/current/cookbook/doctrine/registration_form.html 注册系统正在工作,但我无法