summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]src/com/android/settings/bluetooth/LocalBluetoothManager.java4
-rwxr-xr-x[-rw-r--r--]src/com/android/settings/bluetooth/Utils.java8
2 files changed, 11 insertions, 1 deletions
diff --git a/src/com/android/settings/bluetooth/LocalBluetoothManager.java b/src/com/android/settings/bluetooth/LocalBluetoothManager.java
index 63b8b7c..a1edca1 100644..100755
--- a/src/com/android/settings/bluetooth/LocalBluetoothManager.java
+++ b/src/com/android/settings/bluetooth/LocalBluetoothManager.java
@@ -79,6 +79,10 @@ public final class LocalBluetoothManager {
return mContext;
}
+ public Context getForegroundActivity() {
+ return mForegroundActivity;
+ }
+
boolean isForegroundActivity() {
return mForegroundActivity != null;
}
diff --git a/src/com/android/settings/bluetooth/Utils.java b/src/com/android/settings/bluetooth/Utils.java
index 7d38e17..01e72e0 100644..100755
--- a/src/com/android/settings/bluetooth/Utils.java
+++ b/src/com/android/settings/bluetooth/Utils.java
@@ -89,11 +89,17 @@ final class Utils {
static void showError(Context context, String name, int messageResId) {
String message = context.getString(messageResId, name);
- new AlertDialog.Builder(context)
+ LocalBluetoothManager manager = LocalBluetoothManager.getInstance(context);
+ Context activity = manager.getForegroundActivity();
+ if(manager.isForegroundActivity()) {
+ new AlertDialog.Builder(activity)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(R.string.bluetooth_error_title)
.setMessage(message)
.setPositiveButton(android.R.string.ok, null)
.show();
+ } else {
+ Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
+ }
}
}