Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android-试图完成输入事件,但输入事件接收器已被释放_Java_Android_Mysql - Fatal编程技术网

Java Android-试图完成输入事件,但输入事件接收器已被释放

Java Android-试图完成输入事件,但输入事件接收器已被释放,java,android,mysql,Java,Android,Mysql,在Logcat中显示:试图完成输入事件,但输入事件接收器已被释放 在Catch Block消息框中,我遇到了一个错误,如println需要消息。请帮帮我 我使用Android Studio 2.0 这里是LOGCAT: “12-13 03:48:40.598 2129-2129/com.mysqlapp.bug.mysqlapp W/InputEventReceiver:试图完成输入事件,但输入失败 事件接收器已被释放。“ 这是二等舱: public class MySqlDatabaseHel

在Logcat中显示:试图完成输入事件,但输入事件接收器已被释放

在Catch Block消息框中,我遇到了一个错误,如
println
需要
消息。请帮帮我

我使用Android Studio 2.0

这里是LOGCAT:

“12-13 03:48:40.598 2129-2129/com.mysqlapp.bug.mysqlapp W/InputEventReceiver:试图完成输入事件,但输入失败 事件接收器已被释放。“

这是二等舱:

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();
   }
}
公共类MySqlDatabaseHelper扩展异步任务{
上下文ctx;
字符串方法、用户ID、用户名、密码、postData、结果;
MySqlDatabaseHelper(上下文_ctx)
{
ctx=_ctx;
}
@凌驾
受保护的void onPreExecute(){
super.onPreExecute();
}
@凌驾
受保护的字符串doInBackground(字符串…参数){
试一试{
方法=参数[0]。toString();
if(方法等于(“登录”))
{
userName=params[1].toString();
password=params[2].toString();
URL=新URL(“http://10.0.2.2/Android/login.php");
HttpURLConnection conn=(HttpURLConnection)url.openConnection();
conn.setRequestMethod(“POST”);
conn.setDoInput(真);
conn.setDoInput(真);
OutputStream os=conn.getOutputStream();
OutputStreamWriter osw=新的OutputStreamWriter(os,“UTF-8”);
BufferedWriter bw=新的BufferedWriter(osw);
postData=urlcoder.encode(“uname”、“UTF-8”)+”=“+urlcoder.encode(用户名,“UTF-8”)+”&”+
urlcoder.encode(“密码”,“UTF-8”)+“=”+urlcoder.encode(密码,“UTF-8”);
写入(postData);
bw.flush();
bw.close();
osw.close();
os.close();
InputStream is=conn.getInputStream();
InputStreamReader isr=新的InputStreamReader(即“UTF-8”);
BufferedReader br=新的BufferedReader(isr);
字符串行=”;
而((line=br.readLine())!=null)
{
结果+=行;
}
br.close();
isr.close();
is.close();
连接断开();
返回结果;
}
其他的
{
返回“无”;
}
}
捕获(例外情况除外)
{
字符串err=(例如getMessage()==null)?“发生错误”:例如getMessage();
Log.e(“Err”,Err);
AlertDialog alert=新建AlertDialog.Builder(ctx.create();
alert.setTitle(“出错1”);
alert.setMessage(“-”+ex.getMessage()+“-”);
alert.show();
返回“ERR”;
}
}
@凌驾
受保护的void onProgressUpdate(void…值){
super.onProgressUpdate(值);
}
@凌驾
受保护的void onPostExecute(字符串结果){
AlertDialog alert=新建AlertDialog.Builder(ctx.create();
alert.setTitle(“成功工作”);
alert.setMessage(“-”+结果+“-”);
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();
   }
}