android bluetooth discovery not finding devicesIs there a way to run Python on Android?How do save an Android Activity state using save instance state?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?“Debug certificate expired” error in Eclipse Android pluginsIs there a unique Android device ID?What is 'Context' on Android?Android SDK installation doesn't find JDKProper use cases for Android UserManager.isUserAGoat()?android: Bluetooth won't discover devices
Do sorcerers' Subtle Spells require a skill check to be unseen?
How does Loki do this?
Can the discrete variable be a negative number?
How does buying out courses with grant money work?
How did Doctor Strange see the winning outcome in Avengers: Infinity War?
Crossing the line between justified force and brutality
How do I rename a Linux host without needing to reboot for the rename to take effect?
Pre-amplifier input protection
Sort a list by elements of another list
Energy of the particles in the particle accelerator
Did Dumbledore lie to Harry about how long he had James Potter's invisibility cloak when he was examining it? If so, why?
Term for the "extreme-extension" version of a straw man fallacy?
Was Spock the First Vulcan in Starfleet?
System.debug(JSON.Serialize(o)) Not longer shows full string
Method to test if a number is a perfect power?
Is HostGator storing my password in plaintext?
Return the Closest Prime Number
What is the opposite of 'gravitas'?
Why escape if the_content isnt?
Why does indent disappear in lists?
How do we know the LHC results are robust?
How to Reset Passwords on Multiple Websites Easily?
Avoiding estate tax by giving multiple gifts
Opposite of a diet
android bluetooth discovery not finding devices
Is there a way to run Python on Android?How do save an Android Activity state using save instance state?Close/hide the Android Soft KeyboardWhy is the Android emulator so slow? How can we speed up the Android emulator?“Debug certificate expired” error in Eclipse Android pluginsIs there a unique Android device ID?What is 'Context' on Android?Android SDK installation doesn't find JDKProper use cases for Android UserManager.isUserAGoat()?android: Bluetooth won't discover devices
I have a very simple activity for discovering other android devices via bluetooth:
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
// Get the local Bluetooth adapter
FrameLayout f = new FrameLayout(this);
setContentView(f);
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
this.registerReceiver(mReceiver, filter);
// Register for broadcasts when discovery has finished
filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
this.registerReceiver(mReceiver, filter);
mBtAdapter = BluetoothAdapter.getDefaultAdapter();
// Get a set of currently paired devices
Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();
// Request discover from BluetoothAdapter
Log.i("bluetooth", "about to start device discovery");
mBtAdapter.startDiscovery();
//start receiving stuff
mReceiver = new BluetoothReceiver();
The problem is that the BluetoothRecieiver class called at the end of the activity's onCreate() doesn't seem to find and devices, although I have one turned on in the vicinity when I am debugging this:
public class BluetoothReceiver extends BroadcastReceiver
public ArrayAdapter<String> mNewDevicesArrayAdapter;
@Override
public void onReceive(Context context, Intent intent)
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action))
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// If it's already paired, skip it, because it's been listed already
if (device.getBondState() != BluetoothDevice.BOND_BONDED)
Log.i("face", device.getName() + "n" + device.getAddress());
mNewDevicesArrayAdapter.add(device.getName() + "n" + device.getAddress());
// When discovery is finished, change the Activity title
else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action))
if (mNewDevicesArrayAdapter.getCount() == 0)
Log.i("face", "found NOTHING!");
mNewDevicesArrayAdapter.add("no devices found");
Is there anything I am missing here?
java android bluetooth
add a comment |
I have a very simple activity for discovering other android devices via bluetooth:
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
// Get the local Bluetooth adapter
FrameLayout f = new FrameLayout(this);
setContentView(f);
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
this.registerReceiver(mReceiver, filter);
// Register for broadcasts when discovery has finished
filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
this.registerReceiver(mReceiver, filter);
mBtAdapter = BluetoothAdapter.getDefaultAdapter();
// Get a set of currently paired devices
Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();
// Request discover from BluetoothAdapter
Log.i("bluetooth", "about to start device discovery");
mBtAdapter.startDiscovery();
//start receiving stuff
mReceiver = new BluetoothReceiver();
The problem is that the BluetoothRecieiver class called at the end of the activity's onCreate() doesn't seem to find and devices, although I have one turned on in the vicinity when I am debugging this:
public class BluetoothReceiver extends BroadcastReceiver
public ArrayAdapter<String> mNewDevicesArrayAdapter;
@Override
public void onReceive(Context context, Intent intent)
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action))
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// If it's already paired, skip it, because it's been listed already
if (device.getBondState() != BluetoothDevice.BOND_BONDED)
Log.i("face", device.getName() + "n" + device.getAddress());
mNewDevicesArrayAdapter.add(device.getName() + "n" + device.getAddress());
// When discovery is finished, change the Activity title
else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action))
if (mNewDevicesArrayAdapter.getCount() == 0)
Log.i("face", "found NOTHING!");
mNewDevicesArrayAdapter.add("no devices found");
Is there anything I am missing here?
java android bluetooth
add a comment |
I have a very simple activity for discovering other android devices via bluetooth:
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
// Get the local Bluetooth adapter
FrameLayout f = new FrameLayout(this);
setContentView(f);
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
this.registerReceiver(mReceiver, filter);
// Register for broadcasts when discovery has finished
filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
this.registerReceiver(mReceiver, filter);
mBtAdapter = BluetoothAdapter.getDefaultAdapter();
// Get a set of currently paired devices
Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();
// Request discover from BluetoothAdapter
Log.i("bluetooth", "about to start device discovery");
mBtAdapter.startDiscovery();
//start receiving stuff
mReceiver = new BluetoothReceiver();
The problem is that the BluetoothRecieiver class called at the end of the activity's onCreate() doesn't seem to find and devices, although I have one turned on in the vicinity when I am debugging this:
public class BluetoothReceiver extends BroadcastReceiver
public ArrayAdapter<String> mNewDevicesArrayAdapter;
@Override
public void onReceive(Context context, Intent intent)
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action))
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// If it's already paired, skip it, because it's been listed already
if (device.getBondState() != BluetoothDevice.BOND_BONDED)
Log.i("face", device.getName() + "n" + device.getAddress());
mNewDevicesArrayAdapter.add(device.getName() + "n" + device.getAddress());
// When discovery is finished, change the Activity title
else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action))
if (mNewDevicesArrayAdapter.getCount() == 0)
Log.i("face", "found NOTHING!");
mNewDevicesArrayAdapter.add("no devices found");
Is there anything I am missing here?
java android bluetooth
I have a very simple activity for discovering other android devices via bluetooth:
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
// Get the local Bluetooth adapter
FrameLayout f = new FrameLayout(this);
setContentView(f);
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
this.registerReceiver(mReceiver, filter);
// Register for broadcasts when discovery has finished
filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
this.registerReceiver(mReceiver, filter);
mBtAdapter = BluetoothAdapter.getDefaultAdapter();
// Get a set of currently paired devices
Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();
// Request discover from BluetoothAdapter
Log.i("bluetooth", "about to start device discovery");
mBtAdapter.startDiscovery();
//start receiving stuff
mReceiver = new BluetoothReceiver();
The problem is that the BluetoothRecieiver class called at the end of the activity's onCreate() doesn't seem to find and devices, although I have one turned on in the vicinity when I am debugging this:
public class BluetoothReceiver extends BroadcastReceiver
public ArrayAdapter<String> mNewDevicesArrayAdapter;
@Override
public void onReceive(Context context, Intent intent)
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action))
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// If it's already paired, skip it, because it's been listed already
if (device.getBondState() != BluetoothDevice.BOND_BONDED)
Log.i("face", device.getName() + "n" + device.getAddress());
mNewDevicesArrayAdapter.add(device.getName() + "n" + device.getAddress());
// When discovery is finished, change the Activity title
else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action))
if (mNewDevicesArrayAdapter.getCount() == 0)
Log.i("face", "found NOTHING!");
mNewDevicesArrayAdapter.add("no devices found");
Is there anything I am missing here?
java android bluetooth
java android bluetooth
edited Jun 5 '16 at 17:23
Willi Mentzel
10.5k114971
10.5k114971
asked Jul 3 '13 at 14:19
user1595537user1595537
1015
1015
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I think it's because when you call registerReceiver()
mReceiver
is null, move mReceiver = new BluetoothReceiver();
above the first this.registerReceiver(mReceiver, filter);
, also you could do something like
filter = new IntentFilter();
filter.addAction(BluetoothDevice.ACTION_FOUND);
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
and then call this.registerReceiver(mReceiver, filter);
only one time
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17450548%2fandroid-bluetooth-discovery-not-finding-devices%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think it's because when you call registerReceiver()
mReceiver
is null, move mReceiver = new BluetoothReceiver();
above the first this.registerReceiver(mReceiver, filter);
, also you could do something like
filter = new IntentFilter();
filter.addAction(BluetoothDevice.ACTION_FOUND);
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
and then call this.registerReceiver(mReceiver, filter);
only one time
add a comment |
I think it's because when you call registerReceiver()
mReceiver
is null, move mReceiver = new BluetoothReceiver();
above the first this.registerReceiver(mReceiver, filter);
, also you could do something like
filter = new IntentFilter();
filter.addAction(BluetoothDevice.ACTION_FOUND);
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
and then call this.registerReceiver(mReceiver, filter);
only one time
add a comment |
I think it's because when you call registerReceiver()
mReceiver
is null, move mReceiver = new BluetoothReceiver();
above the first this.registerReceiver(mReceiver, filter);
, also you could do something like
filter = new IntentFilter();
filter.addAction(BluetoothDevice.ACTION_FOUND);
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
and then call this.registerReceiver(mReceiver, filter);
only one time
I think it's because when you call registerReceiver()
mReceiver
is null, move mReceiver = new BluetoothReceiver();
above the first this.registerReceiver(mReceiver, filter);
, also you could do something like
filter = new IntentFilter();
filter.addAction(BluetoothDevice.ACTION_FOUND);
filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
and then call this.registerReceiver(mReceiver, filter);
only one time
edited Mar 8 at 11:34
Faysal Ahmed
4,30651534
4,30651534
answered Jul 3 '13 at 14:44
CampigCampig
10117
10117
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17450548%2fandroid-bluetooth-discovery-not-finding-devices%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown