小编Kem*_*Kod的帖子

java.lang.RuntimeException:无法在未调用Looper.prepare()的线程内创建处理程序

当单击一个按钮时,我使用简单的线程来执行httpGet到服务器,但是我在执行后得到了这个.

Button b_back = (Button) findViewById(R.id.bback);
b_back.setOnClickListener(this);
Button b_sign_up = (Button) findViewById(R.id.signup_button);
b_sign_up.setOnClickListener(this);

@Override
public void onClick(View arg0) 
{
    // TODO Auto-generated method stub
    switch (arg0.getId()) 
    {
        case R.id.bback:
            Intent i = new Intent(this, MainSwitch.class);
            finish();
            startActivity(i);
            break;

            // More buttons go here (if any) ...

        case R.id.signup_button:
            if(username.getText().toString().equalsIgnoreCase("") ||
               password.getText().toString().equalsIgnoreCase("") ||
               email.getText().toString().equalsIgnoreCase(""))
            {
                AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                dialog.setMessage("Please fill in all the gaps!");
                dialog.show();
            }
            else
            {
                //****** Call method that sends the information to server.
                Thread background …
Run Code Online (Sandbox Code Playgroud)

java multithreading android handler looper

0
推荐指数
1
解决办法
9759
查看次数

标签 统计

android ×1

handler ×1

java ×1

looper ×1

multithreading ×1