2

logcat 中没有错误,只是当前活动关闭并且先前的活动打开。

这是我提出蓝牙启用请求的代码:

 bt.setOnClickListener(new OnClickListener() {
           @Override
           public void onClick(View v) {
               if (!(bluetooth.isEnabled())) {
                   Log.e("blue",""+"not working");
                   status = "Bluetooth is not Enabled.";
                   Toast.makeText(AddUser.this, status, Toast.LENGTH_SHORT).show();
                   Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
                startActivityForResult(enableBtIntent, 1);

                }
                else
                {

                    scand();
                }

           }



    });

这是onactivityresult:

protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    System.out.println(resultCode);
    Log.e("resultblue",""+resultCode);
    if (resultCode ==  RESULT_CANCELED) {


        runOnUiThread(new Runnable() {
            public void run() {

             Toast.makeText(AddUser.this, "Error Enabling bluetooth", Toast.LENGTH_LONG).show();
            }
        });
    } else {

            scand();
    }



}

可能是什么问题呢?

4

0 回答 0