diff --git a/src/com/connectsdk/device/DevicePicker.java b/src/com/connectsdk/device/DevicePicker.java index 9e4c655b..943070f9 100644 --- a/src/com/connectsdk/device/DevicePicker.java +++ b/src/com/connectsdk/device/DevicePicker.java @@ -22,6 +22,7 @@ import android.app.Activity; import android.app.AlertDialog; +import android.content.DialogInterface; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; @@ -77,7 +78,7 @@ public void cancelPicker() { * @param message The title for the AlertDialog * @param listener The listener for the ListView to get the item that was clicked on */ - public AlertDialog getPickerDialog(String message, final OnItemClickListener listener) { + public AlertDialog getPickerDialog(String message, final OnItemClickListener listener, DialogInterface.OnCancelListener cancelListener) { final DevicePickerListView view = new DevicePickerListView(activity); TextView title = (TextView) activity.getLayoutInflater().inflate(android.R.layout.simple_list_item_1, null); @@ -85,7 +86,7 @@ public AlertDialog getPickerDialog(String message, final OnItemClickListener lis final AlertDialog pickerDialog = new AlertDialog.Builder(activity) .setCustomTitle(title) - .setCancelable(true) + .setOnCancelListener(cancelListener) .setView(view) .create(); diff --git a/src/com/connectsdk/device/SimpleDevicePicker.java b/src/com/connectsdk/device/SimpleDevicePicker.java index 4aa3aeac..9f85d0bf 100644 --- a/src/com/connectsdk/device/SimpleDevicePicker.java +++ b/src/com/connectsdk/device/SimpleDevicePicker.java @@ -24,6 +24,7 @@ import android.app.Activity; import android.app.Dialog; +import android.content.DialogInterface; import android.content.res.Resources; import android.util.Log; import android.view.View; @@ -138,6 +139,11 @@ public void onItemClick(AdapterView adapter, View view, int pos, selectDevice(device); } + }, new DialogInterface.OnCancelListener() { + @Override + public void onCancel(DialogInterface dialog) { + listener.onPickDeviceFailed(true); + } }); pickerDialog.show();