Hi,
Iam new to android development
I want to enable bluetooth in my app.
I followed the android developer tutorial in the link
https://developer.android.com/guide/topics/connectivity/bluetooth.html
<https://developer.android.com/guide/topics/connectivity/bluetooth.html>
I had used "BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.
getDefaultAdapter();" to get the bluetooth adapter
when i try to check Bluetooth is supported using the commands
if (mBluetoothAdapter == null) {
// Device does not support Bluetooth
}
Iam getting error "unknown class" for mBluetoothAdapter
Also unable to check mBluetoothAdapter.isEnabled(); mBluetoothAdapter and
its methods are not supported.
My objective is to enable ble device and connect and pair with visible
device and to send and receive data.
Looking forward for support
My code in MainActivity.java is
package com.example.rd2_6.myfirstapp;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if(mBluetoothAdapter == null)
{
}
// if (!mBluetoothAdapter.isEnable()) {
// Intent enableBtIntent = new
Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
// startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
// }
public void sendMessage(View view) {
// Intent intent = new Intent(this, DisplayMessageActivity.class);
//EditText editText = (EditText) findViewById(R.id.edit_message);
//String message = editText.getText().toString();
// intent.putExtra(EXTRA_MESSAGE, message);
// startActivity(intent);
}
}
with Thanks
Jagdish
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/8a50da88-aa1b-4dcd-9adc-e8bb9040cc8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.