Reputation: 10400
I created an AlertDialog with a ListView. When the AlertDialog is created it starts also scanning for BLE devices. When the user clicks on one of the items the scanLeDevice
function is called and this will stop further scanning. I would like to know how can I call this function when I click outside the AlertDialog?
public class BLEScan extends AlertDialog {
....
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
bleList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
BLEScan.this.scanLeDevice(false);
selectedBluetoothDevice =(BluetoothDevice) (bleList.getItemAtPosition(i));
BLEScan.this.dismiss();
}
});
Upvotes: 1
Views: 240
Reputation: 3359
Try this.
You can override the onDismiss
method in the DialogFragment
, that is been called when the dialog gets dismissed.
Hope, This may help you!
Upvotes: 1