目标:构建一个Android应用程序,发现范围内BT设备的名称和地址,并将其值提交给Web服务.以前没有将BT设备绑定到主机设备,我只是想在我走动时查看所有内容.
我做了什么:
ACTION_FOUNDs即将到来.事情起作用(使用增量控制台记录测试)直到startDiscovery().
挫折:
如果你能够使用这种方法,我将非常感谢你的智慧.
更新 - 这是一个简化的代码简化版本,让我感到悲伤; 这种简化概括了我的错误.此代码运行,它不会抛出任何cat.log错误或其他错误,它根本不提供任何输出.
package aqu.bttest;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.widget.Toast;
public class BT2Activity extends Activity {
private BluetoothAdapter mBTA;
private SingBroadcastReceiver mReceiver;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//register …Run Code Online (Sandbox Code Playgroud) android bluetooth android-intent android-context android-adapter