Loading src/com/android/settings/bluetooth/LocalBluetoothManager.java 100644 → 100755 +4 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,10 @@ public final class LocalBluetoothManager { return mContext; } public Context getForegroundActivity() { return mForegroundActivity; } boolean isForegroundActivity() { return mForegroundActivity != null; } Loading src/com/android/settings/bluetooth/Utils.java 100644 → 100755 +7 −1 Original line number Diff line number Diff line Loading @@ -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(); } } } Loading
src/com/android/settings/bluetooth/LocalBluetoothManager.java 100644 → 100755 +4 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,10 @@ public final class LocalBluetoothManager { return mContext; } public Context getForegroundActivity() { return mForegroundActivity; } boolean isForegroundActivity() { return mForegroundActivity != null; } Loading
src/com/android/settings/bluetooth/Utils.java 100644 → 100755 +7 −1 Original line number Diff line number Diff line Loading @@ -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(); } } }