在Logcat中显示:尝试完成输入事件但输入事件接收器已被处理
在Catch Block消息框中,我遇到错误,println
需要message
。请帮助我。
我使用Android Studio 2.0
这是LOGCAT:
“12-13 03:48:40.598 2129-2129 / com.mysqlapp.bug.mysqlapp W / InputEventReceiver:尝试完成输入事件但输入 事件接收者已被处置。“
public class MainActivity extends AppCompatActivity {
EditText etUserName,etPassword;
String userName,password;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
etUserName = (EditText) findViewById(R.id.etUserName);
etPassword = (EditText) findViewById(R.id.etPassword);
}
public void btnLoginClick(View v)
{
try
{
userName = etUserName.getText().toString();
password = etPassword.getText().toString();
Log.d("Hello","Here");
MySqlDatabaseHelper sqlCls = new MySqlDatabaseHelper(this);
sqlCls.doInBackground("login",userName,password);
}
catch (Exception ex)
{
AlertDialog alert = new AlertDialog.Builder(this).create();
alert.setTitle("Something Went Wrong");
alert.setMessage("-"+ex.getMessage()+"-");
alert.show();
}
}
}
这是第二类:
public class MySqlDatabaseHelper extends AsyncTask<String,Void,String> {
Context ctx;
String method,userID,userName,password,postData,result;
MySqlDatabaseHelper(Context _ctx)
{
ctx = _ctx;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
try {
method = params[0].toString();
if(method.equals("login"))
{
userName = params[1].toString();
password = params[2].toString();
URL url = new URL("http://10.0.2.2/Android/login.php");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoInput(true);
OutputStream os = conn.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os,"UTF-8");
BufferedWriter bw = new BufferedWriter(osw);
postData = URLEncoder.encode("uname","UTF-8") + "=" + URLEncoder.encode(userName,"UTF-8") + "&" +
URLEncoder.encode("password","UTF-8") + "=" + URLEncoder.encode(password,"UTF-8");
bw.write(postData);
bw.flush();
bw.close();
osw.close();
os.close();
InputStream is = conn.getInputStream();
InputStreamReader isr = new InputStreamReader(is,"UTF-8");
BufferedReader br = new BufferedReader(isr);
String line = "";
while ((line = br.readLine()) != null)
{
result += line;
}
br.close();
isr.close();
is.close();
conn.disconnect();
return result;
}
else
{
return "NONE";
}
}
catch (Exception ex)
{
String err = (ex.getMessage() == null) ? "Error occured" : ex.getMessage();
Log.e("Err",err);
AlertDialog alert = new AlertDialog.Builder(ctx).create();
alert.setTitle("Something Went Wrong1");
alert.setMessage("-"+ex.getMessage()+"-");
alert.show();
return "ERR";
}
}
@Override
protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(String result) {
AlertDialog alert = new AlertDialog.Builder(ctx).create();
alert.setTitle("Successfully Worked");
alert.setMessage("-"+result+"-");
alert.show();
}
}