Jacob
Jacob

Reputation: 15297

Cannot resolve symbol 'getDefaultAdapter()'?

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?

Upvotes: 2

Views: 2915

Answers (1)

Sanjeev
Sanjeev

Reputation: 9946

it seems you should change this

bluetoothAdapter = new BluetoothAdapter.getDefaultAdapter();

to

bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

as the method is a static method.

Upvotes: 4

Related Questions