Bluetooth : fix for crashing alertDialogbox
- changes for crashing of alertDialogbox while displaying message - in showError function, this fix code shoud be added in case of showing error pop up Bug: 5068089 Change-Id: I40e8a699461832b7bd47080b40f467572632d412 Signed-off-by: jhtop.kim <jhtop.kim@samsung.com>
This commit is contained in:
4
src/com/android/settings/bluetooth/LocalBluetoothManager.java
Normal file → Executable file
4
src/com/android/settings/bluetooth/LocalBluetoothManager.java
Normal file → Executable file
@@ -79,6 +79,10 @@ public final class LocalBluetoothManager {
|
|||||||
return mContext;
|
return mContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Context getForegroundActivity() {
|
||||||
|
return mForegroundActivity;
|
||||||
|
}
|
||||||
|
|
||||||
boolean isForegroundActivity() {
|
boolean isForegroundActivity() {
|
||||||
return mForegroundActivity != null;
|
return mForegroundActivity != null;
|
||||||
}
|
}
|
||||||
|
8
src/com/android/settings/bluetooth/Utils.java
Normal file → Executable file
8
src/com/android/settings/bluetooth/Utils.java
Normal file → Executable file
@@ -89,11 +89,17 @@ final class Utils {
|
|||||||
|
|
||||||
static void showError(Context context, String name, int messageResId) {
|
static void showError(Context context, String name, int messageResId) {
|
||||||
String message = context.getString(messageResId, name);
|
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)
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||||
.setTitle(R.string.bluetooth_error_title)
|
.setTitle(R.string.bluetooth_error_title)
|
||||||
.setMessage(message)
|
.setMessage(message)
|
||||||
.setPositiveButton(android.R.string.ok, null)
|
.setPositiveButton(android.R.string.ok, null)
|
||||||
.show();
|
.show();
|
||||||
|
} else {
|
||||||
|
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user