我已经阅读过相关内容,但无论如何都找不到解决问题的方法(这里是初学者......)所以,我目前正在开发一个 Android Studio 应用程序。我刚刚完成了片段以在屏幕上显示不同的选项卡。以前我做过一个“蓝牙和蓝牙服务”活动,效果很好。但是,因为我已经实现了这些片段,所以我收到了这个错误
java.lang.InstantiationException: java.lang.Class<com.example.thibaud.dogbotapp.bluetoothService> has no zero argument consde here
所以我试图做一个空的构造函数,但我不知道如何正确地做......
这是我的 bluetoothService 类的开始:
public class bluetoothService {
private static final String TAG = "bluetoothService";
private static final String appName = "DogBot";
private static final UUID MY_UUID_INSECURE =
UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
private final BluetoothAdapter btAdapter;
Context mContext;
private AcceptThread mInsecureAcceptThread;
private ConnectThread mConnectThread;
private BluetoothDevice mmDevice;
private UUID deviceUUID;
ProgressDialog mProgressDialog;
private ConnectedThread mConnectedThread;
/*public bluetoothService(Context context) {
mContext = context;
btAdapter = BluetoothAdapter.getDefaultAdapter();
start();
}*/
start() 方法在这里:
public synchronized void start() {
Log.d(TAG, "start");
// Cancel any thread attempting to make a connection
if (mConnectThread != null) {
mConnectThread.cancel();
mConnectThread = null;
}
if (mInsecureAcceptThread == null) {
mInsecureAcceptThread = new AcceptThread();
mInsecureAcceptThread.start();
}
}
好吧,第一次在这里发帖,如果不完美,希望你们能提供帮助!谢谢