Domanda

I'm using BluetoothAdapter in android studio 0.4. Project api minSdkVersion 11.

Main activity look as follows:

public class MainActivity extends Activity {

    private BluetoothAdapter bluetoothAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        bluetoothAdapter = new BluetoothAdapter.getDefaultAdapter();
    }
}

The getDefaultAdapter causes: Cannot resolve symbol 'getDefaultAdapter()'.

Any ideas?

È stato utile?

Soluzione

it seems you should change this

bluetoothAdapter = new BluetoothAdapter.getDefaultAdapter();

to

bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

as the method is a static method.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top