我有一个broadcastReciever
来检查传入的意图。传入的intent
包含一个BluetoothDevice
。在BroadcastReceiver
中,我检查天气是否正确BluetoothDevice
。如果是,我想将设备的名称和MAC地址存储在变量中。
我的问题:我只能访问在我的BroadcastReciever中声明为variable
的{{1}}。如何访问const
内部的变量?
BoradcastReceiver
...
namespace firstTry3
{
[Activity(Label = "@string/app_name")]
public class bluetoothConnectionActivity : AppCompatActivity
{
BluetoothAdapter mBluetoothAdapter;
Button buttonBluetoothOn;
Button buttonConnect;
Button buttonDissconnect;
const string deviceName = "HC-05"; //must be changed when bluetooth Device gets new name
string deviceMAC = "";
const string tag = "blueApp";
btdeviceFoundBroadcastReceiver mBtBroadcastReciever;
我无法访问deviceMAC,但出现以下错误: “非静态字段,方法或属性bluetoothConnectionActivity.deviceMethod需要对象引用”