开发者社区> 问答> 正文

Android Studio getSlotFromBufferLocked:未知的缓冲?mysql

我想进行一个简单的登录和注册应用程序,以便用户可以创建一个帐户。(名称,用户名,密码)我使用WAMP和存储帐户的MYSQL数据库。

当我在注册表格上填写用户信息并单击注册时,出现以下错误:

09-14 09:30:39.864 2624-2638/com.example.appname.appname E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xab7115e0 09-14 09:30:48.632 2624-2638/com.example.appname.appname E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xab7125a0 09-14 09:30:51.940 2624-2638/com.example.appname.appname E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xab7125a0 当我去检查数据库时,它没有存储帐户。

MainActivity.java

import android.app.Activity; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}
public void userReg(View v)
{
    startActivity(new Intent(this, Register.class));
}
public void userLogin(View view)
{


}

} 注册.java

import android.app.Activity; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.EditText;

public class Register extends Activity { EditText ET_NAME,ET_USER_NAME,ET_USER_PASS; String name,user_name,user_pass;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.register_layout);
    ET_NAME = (EditText) findViewById(R.id.name);
    ET_USER_NAME = (EditText) findViewById(R.id.new_user_name);
    ET_USER_PASS = (EditText) findViewById(R.id.new_user_pass);
}

public void userReg(View view)
{
    name = ET_NAME.getText().toString();
    user_name = ET_USER_NAME.getText().toString();
    user_pass = ET_USER_PASS.getText().toString();
    String method = "register";
    BackgroundTask backgroundTask = new BackgroundTask(Register.this);
    backgroundTask.execute(method,name,user_name,user_pass);
    finish();
}

} Backgroundtask.java

import android.app.AlertDialog; import android.content.Context; import android.os.AsyncTask; import android.widget.Toast;

import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder;

public class BackgroundTask extends AsyncTask<String, Void, String> { AlertDialog alertDialog; Context ctx;

BackgroundTask(Context ctx) {
    this.ctx = ctx;

}

@Override
protected void onPreExecute() {
    super.onPreExecute();
}

@Override
protected String doInBackground(String... params) {
    String reg_url = "http://10.0.2.2.2/webapp/register.php";
    String login_url = "http://10.0.2.2.2/webapp/login.php";
    String method = params[0];
    if (method.equals("register")) {
        String name = params[1];
        String user_name = params[2];
        String user_pass = params[3];
        try {
            URL url = new URL(reg_url);
            HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
            httpURLConnection.setRequestMethod("POST");
            httpURLConnection.setDoOutput(true);
            OutputStream OS = httpURLConnection.getOutputStream();
            BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(OS, "UTF-8"));
            String data = URLEncoder.encode("user", "UTF-8") + "=" + URLEncoder.encode(name, "UTF-8") + "&" +
                    URLEncoder.encode("user_name", "UTF-8") + "=" + URLEncoder.encode(user_name, "UTF-8") + "&" +
                    URLEncoder.encode("user_pass", "UTF-8") + "=" + URLEncoder.encode(user_pass, "UTF-8");
            bufferedWriter.write(data);
            bufferedWriter.flush();
            bufferedWriter.close();
            OS.close();
            InputStream IS = httpURLConnection.getInputStream();
            IS.close();
            return "Registration Success...";
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    return null;
}

@Override
protected void onProgressUpdate(Void... values) {
    super.onProgressUpdate(values);
}

@Override
protected void onPostExecute(String result) {
    Toast.makeText(ctx, result, Toast.LENGTH_LONG).show();
}

} register.php

Data insertion success..."; } else{ //echo "Data insertion error..".mysqli_error($con); } ?> init.php Database connection success....."; } ?>

展开
收起
保持可爱mmm 2020-05-17 19:25:15 678 0
1 条回答
写回答
取消 提交回答
  • 我相信这是棉花糖特有的。您正在使用棉花糖设备吗?

    我注意到,每次我在应用程序之间切换(无关紧要)或退出应用程序以及销毁活动时,都会打印出此错误。

    我试过在两个Nexus 5s上运行相同的应用程序-一个运行Lollipop,另一个运行棉花糖,并且这些日志打印仅出现在棉花糖版本上-与每个应用程序一起使用,而不仅仅是我正在构建的一个。

    不知道为什么会这样,但是我在这里打开了一个报告。来源:stack overflow

    2020-05-17 19:25:32
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
58同城Android客户端Walle框架演进与实践之路 立即下载
Android组件化实现 立即下载
蚂蚁聚宝Android秒级编译——Freeline 立即下载

相关镜像