I am new to Stackoverflow.
I get the following error and do not understand why:
incompatible types: cannot be converted to Context
Code snippet:
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// Add the name and address to an array adapter to show in a ListView
if (PackageManager.PERMISSION_GRANTED != ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT)) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
The error line did not show up! The error line is: if (PackageManager.PERMISSION_GRANTED != ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT)) {
I have permissions set in my .xml file. I am very new to Android Studio!
Event Log output: C:\Users\jsla3009\AndroidStudioProjects\Test_Bluetooth\app\src\main\java\com\example\test_bluetooth\MainActivity.java:97: error: incompatible types: cannot be converted to Context if (PackageManager.PERMISSION_GRANTED != ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT)) { ^ C:\Users\jsla3009\AndroidStudioProjects\Test_Bluetooth\app\src\main\java\com\example\test_bluetooth\MainActivity.java: uses or overrides a deprecated API. Recompile with -Xlint:deprecation for details. C:\Users\jsla3009\AndroidStudioProjects\Test_Bluetooth\app\src\main\java\com\example\test_bluetooth\MainActivity.java: uses unchecked or unsafe operations. Recompile with -Xlint:unchecked for details. Some messages have been simplified; recompile with -Xdiags:verbose to get full output