-------------------------------------------- On Wed, 2/22/17, kjagdish <kjagdish.sal...@gmail.com> wrote:
Subject: Re: [android-developers] Re: enabling bluetooth in android To: android-developers@googlegroups.com, rprpil...@gmail.com Date: Wednesday, February 22, 2017, 5:58 AM Hi Rajeev, Yes, problem is solved, Solution isdeclare : private static final int REQUEST_ENABLE_BT = 1;private BluetoothAdapter mBluetoothAdapter; in onCreate() methodfinal BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUET OOTH_SERVICE); mBluetoothAdapter = bluetoothManager.getAdapter(); // use this to get the bluetooth adapter if (mBluetoothAdapter == null || !mBluetoothAdapter.isEnabled() ) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION _REQUEST_ENABLE); startActivityForResult( enableBtIntent, REQUEST_ENABLE_BT); } Below link will be usefulhttps://developer.android.com/ guide/topics/connectivity/ bluetooth-le.html with best regards,Jagdish On Wed, Feb 22, 2017 at 1:08 AM, RJ <rprpil...@gmail.com> wrote: Hi Jag, were you able to solve the mBluetoothAdapter issue? I have the same issues. Regards,Rajeev On Monday, August 29, 2016 at 12:53:49 AM UTC-5, Kjagdish Gowda wrote: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.htmlI had used "BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAda pter();" to get the bluetooth adapterwhen i try to check Bluetooth is supported using the commandsif (mBluetoothAdapter == null) { // Device does not support Bluetooth} Iam getting error "unknown class" for mBluetoothAdapterAlso unable to check mBluetoothAdapter.isEnab led(); 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.BluetoothAda pter; import android.bluetooth.BluetoothDev ice; import android.bluetooth.BluetoothMan ager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageMana ger; import android.support.v7.app.AppComp atActivity; 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.MESSAG E"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceSt ate); setContentView(R.layout.activi ty_main); } BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAda pter(); if(mBluetoothAdapter == null) { } // if (!mBluetoothAdapter.isEnable() ) { // Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION _REQUEST_ENABLE); // startActivityForResult(enableB tIntent, 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 ThanksJagdish -- You received this message because you are subscribed to a topic in the Google Groups "Android Developers" group. To unsubscribe from this topic, visit https://groups.google.com/d/ topic/android-developers/ oIOIObplIBs/unsubscribe. To unsubscribe from this group and all its topics, send an email to android-developers+ unsubscr...@googlegroups.com. To post to this group, send email to android-developers@ googlegroups.com. 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/ a8ae56e0-e13c-439a-b4da- a37286b6a891%40googlegroups. com. For more options, visit https://groups.google.com/d/ optout. -- with Thanks & Regards, K Jagatheeswaran Sr. Engineer- R&D -- 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 android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. 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/CAG1nM7obr%3Du0i%3DG5Dhk2tTYb8ZgCGmgj3-ZtdJ2hQ0TY1F0dDQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout. piratie pentru compozitori in special pentru cei atrasi de creatia corala. in -- 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 android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. 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/536181932.2285091.1487744899367%40mail.yahoo.com. For more options, visit https://groups.google.com/d/optout.