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;








-1















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










share|improve this question


























  • This didn't work means what exactly

    – Marcin Orlowski
    Mar 27 at 0:49

















-1















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










share|improve this question


























  • This didn't work means what exactly

    – Marcin Orlowski
    Mar 27 at 0:49













-1












-1








-1


1






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










share|improve this question
















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 android bluetooth






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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
















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












1 Answer
1






active

oldest

votes


















0














Okay the info you provided is incomplete so here is my guesswork.



  1. You have adapter BTArrayAdapter instance but you are not using it.

  2. You seems to have btlist but trying to use btlist2

  3. You are building AlertDialog but not showing it.

  4. 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:



  1. Once you created your adapter, you need to populate it with data somehow, e.g. BTArrayAdapter.addAll(btlist);

  2. Make sure you're using the data list you are actually populating (btlist)

  3. Once you built your dialog, make sure to show it (builder.create().show();)

  4. 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)


  5. I think instead of setItems of AlertDialog.Builder you 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.






share|improve this answer
























    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
    );



    );













    draft saved

    draft discarded


















    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









    0














    Okay the info you provided is incomplete so here is my guesswork.



    1. You have adapter BTArrayAdapter instance but you are not using it.

    2. You seems to have btlist but trying to use btlist2

    3. You are building AlertDialog but not showing it.

    4. 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:



    1. Once you created your adapter, you need to populate it with data somehow, e.g. BTArrayAdapter.addAll(btlist);

    2. Make sure you're using the data list you are actually populating (btlist)

    3. Once you built your dialog, make sure to show it (builder.create().show();)

    4. 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)


    5. I think instead of setItems of AlertDialog.Builder you 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.






    share|improve this answer





























      0














      Okay the info you provided is incomplete so here is my guesswork.



      1. You have adapter BTArrayAdapter instance but you are not using it.

      2. You seems to have btlist but trying to use btlist2

      3. You are building AlertDialog but not showing it.

      4. 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:



      1. Once you created your adapter, you need to populate it with data somehow, e.g. BTArrayAdapter.addAll(btlist);

      2. Make sure you're using the data list you are actually populating (btlist)

      3. Once you built your dialog, make sure to show it (builder.create().show();)

      4. 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)


      5. I think instead of setItems of AlertDialog.Builder you 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.






      share|improve this answer



























        0












        0








        0







        Okay the info you provided is incomplete so here is my guesswork.



        1. You have adapter BTArrayAdapter instance but you are not using it.

        2. You seems to have btlist but trying to use btlist2

        3. You are building AlertDialog but not showing it.

        4. 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:



        1. Once you created your adapter, you need to populate it with data somehow, e.g. BTArrayAdapter.addAll(btlist);

        2. Make sure you're using the data list you are actually populating (btlist)

        3. Once you built your dialog, make sure to show it (builder.create().show();)

        4. 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)


        5. I think instead of setItems of AlertDialog.Builder you 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.






        share|improve this answer













        Okay the info you provided is incomplete so here is my guesswork.



        1. You have adapter BTArrayAdapter instance but you are not using it.

        2. You seems to have btlist but trying to use btlist2

        3. You are building AlertDialog but not showing it.

        4. 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:



        1. Once you created your adapter, you need to populate it with data somehow, e.g. BTArrayAdapter.addAll(btlist);

        2. Make sure you're using the data list you are actually populating (btlist)

        3. Once you built your dialog, make sure to show it (builder.create().show();)

        4. 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)


        5. I think instead of setItems of AlertDialog.Builder you 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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 27 at 0:44









        rorror

        7216 silver badges11 bronze badges




        7216 silver badges11 bronze badges





















            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.



















            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

            밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

            1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴