Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7044551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:25:24+00:00 2026-05-28T02:25:24+00:00

I usually use this private void ensureDiscoverable() { if(D) Log.d(TAG, ensure discoverable); if (mBluetoothAdapter.getScanMode()

  • 0

I usually use this

private void ensureDiscoverable() {
    if(D) Log.d(TAG, "ensure discoverable");
    if (mBluetoothAdapter.getScanMode() !=
            BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
        Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
        startActivity(discoverableIntent);
    }
}

But that prompts a user confirmation. Is there a way to bypass this programmatically?

Also, I suppose there are no “news” on the “always discoverable mode” ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:25:24+00:00Added an answer on May 28, 2026 at 2:25 am

    After some research I concluded that setting discoverable timeout without user interaction it’s only possible with root access (as already suggested in the previous answer). However for someone who need that here is the necessary solution:

    private void ensureBluetoothDiscoverability() {
        try {
            IBluetooth mBtService = getIBluetooth();
            Log.d("TESTE", "Ensuring bluetoot is discoverable");
            if(mBtService.getScanMode() != BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
                Log.e("TESTE", "Device was not in discoverable mode");
                try {
                    mBtService.setDiscoverableTimeout(100);
                    // mBtService.setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE, 1000);
                } catch(Exception e) {
                    Log.e("TESTE", "Error setting bt discoverable",e);
                }
                Log.i("TESTE", "Device must be discoverable");
            } else {
                Log.e("TESTE", "Device already discoverable");
            }
        } catch(Exception e) {
            Log.e("TESTE", "Error ensuring BT discoverability", e);
        }    
    }
    

    <uses-permission android:name="android.permission.WRITE_SETTINGS" />  
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
    

    And then create a new package android.bluetooth, place two files inside IBluetooth.aidl and IBluetoothCallback.aidl and put inside the code as shown here.

    This will allow to access functions that are not available on the standard API, but for some of them you will need permission to “write secure settings” (the comment line above is where you will get that exception for lack of permissions of the process/user).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I usually use this line to import file from out of the current folder
I usually use like this $ find -name testname.c ./dir1/dir2/testname.c $ vi ./dir1/dir2/testname.c it's
private void DisplayImages(string imageFile) { Image pImage = new Image(); pImage.ImageUrl = imageFile; this.Controls.Add(pImage);
I usually use Visual Studio Team System 2008 Source Control Explorer with TFS, but
I usually use the following pipeline to grep for a particular search string and
I usually use pointers in the following manner char *ptr = malloc( sizeof(char) *
I usually use a TabControl and somehow hide the tabs and navigate through them.
I usually use ORM instead of SQL and I am slightly out of touch
I usually use JSON with jQuery to just return a string with html. However,
I usually use ax.set_rasterized(True) to rasterize the figure so that it could handle transparency

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.