Android selectable Bluetooth ListIs there a way to run Python on Android?How to 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?Proper use cases for Android UserManager.isUserAGoat()?How to Delete item in ListView and Database - Android StudiosetText on button from another activity android
Why does Beijing's new Daxing airport have so few gates?
A conjectural trigonometric identity
Is Norway in the Single Market?
What is the name of this type of figure?
Can the additional attack from a Samurai's Rapid Strike have advantage?
"DDoouubbllee ssppeeaakk!!"
Can living where magnetic ore is abundant provide any protection from cosmic radiation?
How can flights operated by the same company have such different prices when marketed by another?
UX writing: When to use "we"?
"Will flex for food". What does this phrase mean?
Return last number in sub-sequences in a list of integers
Password management for kids - what's a good way to start?
Why don't short runways use ramps for takeoff?
A coworker mumbles to herself when working. How can I ask her to stop?
May a hotel provide accommodation for fewer people than booked?
Using Python in a Bash Script
How to innovate in OR
Skipping same old introductions
Get content of CMS Block in Magento 1.x
Conflict between senior and junior members
How can a class have multiple methods without breaking the single responsibility principle
How to trick a fairly simplistic kill-counter?
Could flaps be raised upward to serve as spoilers / lift dumpers?
Is this popular optical illusion made of a grey-scale image with coloured lines?
Android selectable Bluetooth List
Is there a way to run Python on Android?How to 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?Proper use cases for Android UserManager.isUserAGoat()?How to Delete item in ListView and Database - Android StudiosetText on button from another activity android
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
How can I make a popup on Android so when you click one of the devices it saves the device name to a variable. When I do it nothing happens and I really need some help with how to figure this out.
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null)
// No bluetooth support on device
if (mBluetoothAdapter != null)
if (!mBluetoothAdapter.isEnabled())
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
String[] btarray;
List<String> btlist = new ArrayList<String>();
BTArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
// get paired devices
pairedDevices = mBluetoothAdapter.getBondedDevices();
// put it's one to the adapter
for(BluetoothDevice device : pairedDevices)
btlist.add(device.getAddress());
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("BT")
.setItems(btlist2, new DialogInterface.OnClickListener()
public void onClick(DialogInterface dialog, int which)
// The 'which' argument contains the index position
// of the selected item
);
builder.create();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("BT")
.setItems(btlist2, new DialogInterface.OnClickListener()
public void onClick(DialogInterface dialog, int which)
// The 'which' argument contains the index position
// of the selected item
);
builder.create();
This didn't work
java
add a comment |
How can I make a popup on Android so when you click one of the devices it saves the device name to a variable. When I do it nothing happens and I really need some help with how to figure this out.
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null)
// No bluetooth support on device
if (mBluetoothAdapter != null)
if (!mBluetoothAdapter.isEnabled())
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
String[] btarray;
List<String> btlist = new ArrayList<String>();
BTArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
// get paired devices
pairedDevices = mBluetoothAdapter.getBondedDevices();
// put it's one to the adapter
for(BluetoothDevice device : pairedDevices)
btlist.add(device.getAddress());
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("BT")
.setItems(btlist2, new DialogInterface.OnClickListener()
public void onClick(DialogInterface dialog, int which)
// The 'which' argument contains the index position
// of the selected item
);
builder.create();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("BT")
.setItems(btlist2, new DialogInterface.OnClickListener()
public void onClick(DialogInterface dialog, int which)
// The 'which' argument contains the index position
// of the selected item
);
builder.create();
This didn't work
java
This didn't workmeans what exactly
– Marcin Orlowski
Mar 27 at 0:49
add a comment |
How can I make a popup on Android so when you click one of the devices it saves the device name to a variable. When I do it nothing happens and I really need some help with how to figure this out.
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null)
// No bluetooth support on device
if (mBluetoothAdapter != null)
if (!mBluetoothAdapter.isEnabled())
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
String[] btarray;
List<String> btlist = new ArrayList<String>();
BTArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
// get paired devices
pairedDevices = mBluetoothAdapter.getBondedDevices();
// put it's one to the adapter
for(BluetoothDevice device : pairedDevices)
btlist.add(device.getAddress());
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("BT")
.setItems(btlist2, new DialogInterface.OnClickListener()
public void onClick(DialogInterface dialog, int which)
// The 'which' argument contains the index position
// of the selected item
);
builder.create();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("BT")
.setItems(btlist2, new DialogInterface.OnClickListener()
public void onClick(DialogInterface dialog, int which)
// The 'which' argument contains the index position
// of the selected item
);
builder.create();
This didn't work
java
How can I make a popup on Android so when you click one of the devices it saves the device name to a variable. When I do it nothing happens and I really need some help with how to figure this out.
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null)
// No bluetooth support on device
if (mBluetoothAdapter != null)
if (!mBluetoothAdapter.isEnabled())
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
String[] btarray;
List<String> btlist = new ArrayList<String>();
BTArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
// get paired devices
pairedDevices = mBluetoothAdapter.getBondedDevices();
// put it's one to the adapter
for(BluetoothDevice device : pairedDevices)
btlist.add(device.getAddress());
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("BT")
.setItems(btlist2, new DialogInterface.OnClickListener()
public void onClick(DialogInterface dialog, int which)
// The 'which' argument contains the index position
// of the selected item
);
builder.create();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("BT")
.setItems(btlist2, new DialogInterface.OnClickListener()
public void onClick(DialogInterface dialog, int which)
// The 'which' argument contains the index position
// of the selected item
);
builder.create();
This didn't work
java
java
edited Mar 26 at 23:53
Hoppeduppeanut
5842 gold badges11 silver badges18 bronze badges
5842 gold badges11 silver badges18 bronze badges
asked Mar 26 at 23:03
Andrew Van OstrandAndrew Van Ostrand
13 bronze badges
13 bronze badges
This didn't workmeans what exactly
– Marcin Orlowski
Mar 27 at 0:49
add a comment |
This didn't workmeans what exactly
– Marcin Orlowski
Mar 27 at 0:49
This didn't work means what exactly– Marcin Orlowski
Mar 27 at 0:49
This didn't work means what exactly– Marcin Orlowski
Mar 27 at 0:49
add a comment |
1 Answer
1
active
oldest
votes
Okay the info you provided is incomplete so here is my guesswork.
- You have adapter
BTArrayAdapterinstance but you are not using it. - You seems to have
btlistbut trying to usebtlist2 - You are building AlertDialog but not showing it.
- Not sure if you are correctly requesting bluetooth permissions as you did not provide the info
So these are the things you need to check:
- Once you created your adapter, you need to populate it with data somehow, e.g.
BTArrayAdapter.addAll(btlist); - Make sure you're using the data list you are actually populating (
btlist) - Once you built your dialog, make sure to show it (
builder.create().show();) - Make sure you have
<uses-permission android:name="android.permission.BLUETOOTH" />in your manifest and make sure you are requesting location permissions dynamically (better try to populate list manually and see if it's showing, then you'll know it's something wrong with the permissions request) I think instead of
setItemsofAlertDialog.Builderyou should be using:.setAdapter(BTArrayAdapter, new DialogInterface.OnClickListener()
@Override
public void onClick(DialogInterface dialogInterface, int i)
);
PS.: actually you are not discovering so you probably don't need to ask for location permissions.
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%2f55367430%2fandroid-selectable-bluetooth-list%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
Okay the info you provided is incomplete so here is my guesswork.
- You have adapter
BTArrayAdapterinstance but you are not using it. - You seems to have
btlistbut trying to usebtlist2 - You are building AlertDialog but not showing it.
- Not sure if you are correctly requesting bluetooth permissions as you did not provide the info
So these are the things you need to check:
- Once you created your adapter, you need to populate it with data somehow, e.g.
BTArrayAdapter.addAll(btlist); - Make sure you're using the data list you are actually populating (
btlist) - Once you built your dialog, make sure to show it (
builder.create().show();) - Make sure you have
<uses-permission android:name="android.permission.BLUETOOTH" />in your manifest and make sure you are requesting location permissions dynamically (better try to populate list manually and see if it's showing, then you'll know it's something wrong with the permissions request) I think instead of
setItemsofAlertDialog.Builderyou should be using:.setAdapter(BTArrayAdapter, new DialogInterface.OnClickListener()
@Override
public void onClick(DialogInterface dialogInterface, int i)
);
PS.: actually you are not discovering so you probably don't need to ask for location permissions.
add a comment |
Okay the info you provided is incomplete so here is my guesswork.
- You have adapter
BTArrayAdapterinstance but you are not using it. - You seems to have
btlistbut trying to usebtlist2 - You are building AlertDialog but not showing it.
- Not sure if you are correctly requesting bluetooth permissions as you did not provide the info
So these are the things you need to check:
- Once you created your adapter, you need to populate it with data somehow, e.g.
BTArrayAdapter.addAll(btlist); - Make sure you're using the data list you are actually populating (
btlist) - Once you built your dialog, make sure to show it (
builder.create().show();) - Make sure you have
<uses-permission android:name="android.permission.BLUETOOTH" />in your manifest and make sure you are requesting location permissions dynamically (better try to populate list manually and see if it's showing, then you'll know it's something wrong with the permissions request) I think instead of
setItemsofAlertDialog.Builderyou should be using:.setAdapter(BTArrayAdapter, new DialogInterface.OnClickListener()
@Override
public void onClick(DialogInterface dialogInterface, int i)
);
PS.: actually you are not discovering so you probably don't need to ask for location permissions.
add a comment |
Okay the info you provided is incomplete so here is my guesswork.
- You have adapter
BTArrayAdapterinstance but you are not using it. - You seems to have
btlistbut trying to usebtlist2 - You are building AlertDialog but not showing it.
- Not sure if you are correctly requesting bluetooth permissions as you did not provide the info
So these are the things you need to check:
- Once you created your adapter, you need to populate it with data somehow, e.g.
BTArrayAdapter.addAll(btlist); - Make sure you're using the data list you are actually populating (
btlist) - Once you built your dialog, make sure to show it (
builder.create().show();) - Make sure you have
<uses-permission android:name="android.permission.BLUETOOTH" />in your manifest and make sure you are requesting location permissions dynamically (better try to populate list manually and see if it's showing, then you'll know it's something wrong with the permissions request) I think instead of
setItemsofAlertDialog.Builderyou should be using:.setAdapter(BTArrayAdapter, new DialogInterface.OnClickListener()
@Override
public void onClick(DialogInterface dialogInterface, int i)
);
PS.: actually you are not discovering so you probably don't need to ask for location permissions.
Okay the info you provided is incomplete so here is my guesswork.
- You have adapter
BTArrayAdapterinstance but you are not using it. - You seems to have
btlistbut trying to usebtlist2 - You are building AlertDialog but not showing it.
- Not sure if you are correctly requesting bluetooth permissions as you did not provide the info
So these are the things you need to check:
- Once you created your adapter, you need to populate it with data somehow, e.g.
BTArrayAdapter.addAll(btlist); - Make sure you're using the data list you are actually populating (
btlist) - Once you built your dialog, make sure to show it (
builder.create().show();) - Make sure you have
<uses-permission android:name="android.permission.BLUETOOTH" />in your manifest and make sure you are requesting location permissions dynamically (better try to populate list manually and see if it's showing, then you'll know it's something wrong with the permissions request) I think instead of
setItemsofAlertDialog.Builderyou should be using:.setAdapter(BTArrayAdapter, new DialogInterface.OnClickListener()
@Override
public void onClick(DialogInterface dialogInterface, int i)
);
PS.: actually you are not discovering so you probably don't need to ask for location permissions.
answered Mar 27 at 0:44
rorror
7216 silver badges11 bronze badges
7216 silver badges11 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
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%2f55367430%2fandroid-selectable-bluetooth-list%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
This didn't workmeans what exactly– Marcin Orlowski
Mar 27 at 0:49