简体   繁体   中英

bluetooth enabling dialog - HOME button disabling

all my activities use code below to disable home button:

@Override
public void onAttachedToWindow()
{  
       this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);     
       super.onAttachedToWindow();  
}

but main activity turn bluetooth ON by

        Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        startActivityForResult(enableIntent, REQUEST_ENABLE_BT);

that open bluetooth enabling dialog

How can I prevent exit my app in this case?

Problem was solved by

BluetoothAdapter.enable()

and listening for the ACTION_STATE_CHANGED broadcast Intent.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM