Example usage for android.app AlertDialog.Builder setCancelable

List of usage examples for android.app AlertDialog.Builder setCancelable

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setCancelable.

Prototype

public void setCancelable(boolean flag) 

Source Link

Document

Sets whether this dialog is cancelable with the KeyEvent#KEYCODE_BACK BACK key.

Usage

From source file:at.jclehner.rxdroid.DrugListActivity.java

@SuppressWarnings("deprecation")
@Override/*w ww.  j  a va 2s.  c  om*/
protected Dialog onCreateDialog(final int id, Bundle args) {
    if (id == R.id.dose_dialog)
        return new DoseDialog(this);
    else if (id == DIALOG_INFO) {
        final String msg = args.getString("msg");
        final String onceId = args.getString("once_id");

        final AlertDialog.Builder ab = new AlertDialog.Builder(this);
        ab.setIcon(android.R.drawable.ic_dialog_info);
        ab.setTitle(R.string._title_info);
        ab.setMessage(msg);
        ab.setCancelable(false);
        ab.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                Log.d(TAG, "onClick: which = " + which);
                Settings.setDisplayedOnce(onceId);
                removeDialog(id);
            }
        });

        return ab.create();
    }

    return super.onCreateDialog(id, args);
}

From source file:bulat.diet.helper_couch.common.fragment.ExpandableItemPinnedMessageDialogFragment.java

@NonNull
@Override//from   w  w  w  .j a v  a  2  s  . c  o  m
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    final int groupPosition = getArguments().getInt(KEY_GROUP_ITEM_POSITION, Integer.MIN_VALUE);
    final int childPosition = getArguments().getInt(KEY_CHILD_ITEM_POSITION, Integer.MIN_VALUE);

    // for expandable list
    if (childPosition == RecyclerView.NO_POSITION) {
        //  builder.setMessage(getString(R.string.dialog_message_group_item_pinned, groupPosition));
    } else {
        // builder.setMessage(getString(R.string.dialog_message_child_item_pinned, groupPosition, childPosition));
    }
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            notifyItemPinnedDialogDismissed(true);
        }
    });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    builder.setCancelable(true);
    return builder.create();
}

From source file:com.android.mms.ui.MessageListItem.java

private void bindNotifInd() {
    showMmsView(false);//from   w  ww. ja v  a 2s  . c  o  m

    mBodyTextView.setText(formatMessage(mMessageItem, null, mMessageItem.mSubject, mMessageItem.mHighlight,
            mMessageItem.mTextContentType));

    mDateView.setText(buildTimestampLine(mMessageItem.mTimestamp));

    final String msgSizeText = mContext.getString(R.string.message_size_label)
            + String.valueOf((mMessageItem.mMessageSize + 1023) / 1024) + mContext.getString(R.string.kilobyte);

    mMessageSizeView.setText(msgSizeText);
    mMessageSizeView.setVisibility(View.VISIBLE);

    updateSimIndicatorView(mMessageItem.mSubId);

    switch (mMessageItem.getMmsDownloadStatus()) {
    case DownloadManager.STATE_PRE_DOWNLOADING:
    case DownloadManager.STATE_DOWNLOADING:
        showDownloadingAttachment();
        break;
    case DownloadManager.STATE_UNKNOWN:
    case DownloadManager.STATE_UNSTARTED:
        DownloadManager downloadManager = DownloadManager.getInstance();
        boolean autoDownload = downloadManager.isAuto();
        boolean dataSuspended = (MmsApp.getApplication().getTelephonyManager()
                .getDataState() == TelephonyManager.DATA_SUSPENDED);

        // If we're going to automatically start downloading the mms attachment, then
        // don't bother showing the download button for an instant before the actual
        // download begins. Instead, show downloading as taking place.
        if (autoDownload && !dataSuspended) {
            showDownloadingAttachment();
            break;
        }
    case DownloadManager.STATE_TRANSIENT_FAILURE:
    case DownloadManager.STATE_PERMANENT_FAILURE:
    default:
        setLongClickable(true);
        inflateDownloadControls();
        mDownloading.setVisibility(View.GONE);
        mDownloadButton.setVisibility(View.VISIBLE);
        mDownloadButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mDownloading.setVisibility(View.VISIBLE);
                try {
                    NotificationInd nInd = (NotificationInd) PduPersister.getPduPersister(mContext)
                            .load(mMessageItem.mMessageUri);
                    Log.d(TAG, "Download notify Uri = " + mMessageItem.mMessageUri);
                    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
                    builder.setTitle(R.string.download);
                    builder.setCancelable(true);
                    // Judge notification weather is expired
                    if (nInd.getExpiry() < System.currentTimeMillis() / 1000L) {
                        // builder.setIcon(R.drawable.ic_dialog_alert_holo_light);
                        builder.setMessage(mContext.getString(R.string.service_message_not_found));
                        builder.show();
                        SqliteWrapper.delete(mContext, mContext.getContentResolver(), mMessageItem.mMessageUri,
                                null, null);
                        return;
                    }
                    // Judge whether memory is full
                    else if (MessageUtils.isMmsMemoryFull()) {
                        builder.setMessage(mContext.getString(R.string.sms_full_body));
                        builder.show();
                        return;
                    }
                    // Judge whether message size is too large
                    else if ((int) nInd.getMessageSize() > MmsConfig.getMaxMessageSize()) {
                        builder.setMessage(mContext.getString(R.string.mms_too_large));
                        builder.show();
                        return;
                    }
                } catch (MmsException e) {
                    Log.e(TAG, e.getMessage(), e);
                    return;
                }
                mDownloadButton.setVisibility(View.GONE);
                Intent intent = new Intent(mContext, TransactionService.class);
                intent.putExtra(TransactionBundle.URI, mMessageItem.mMessageUri.toString());
                intent.putExtra(TransactionBundle.TRANSACTION_TYPE, Transaction.RETRIEVE_TRANSACTION);
                intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mMessageItem.mSubId);

                mContext.startService(intent);

                DownloadManager.getInstance().markState(mMessageItem.mMessageUri,
                        DownloadManager.STATE_PRE_DOWNLOADING);
            }
        });
        break;
    }

    // Hide the indicators.
    mLockedIndicator.setVisibility(View.GONE);
    mDeliveredIndicator.setVisibility(View.GONE);
    mDetailsIndicator.setVisibility(View.GONE);
    updateAvatarView(mMessageItem.mAddress, false);
}

From source file:com.google.sample.cast.refplayer.chatting.MainActivity.java

public void setDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Type Your Name");
    final EditText InputName = new EditText(this);
    InputName.setInputType(InputType.TYPE_CLASS_TEXT);
    builder.setView(InputName);//from  www.j  a  v a2s  .  c  o  m
    builder.setPositiveButton(R.string.start_chatting, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            UserName = InputName.getText().toString();
        }
    });
    builder.setCancelable(false);
    dialog = builder.create();

    InputName.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (s.length() < 1 || s.length() > 20) {
                dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
            } else {
                dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
            }
        }
    });

    dialog.show();
    dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}

From source file:com.dsi.ant.antplus.pluginsampler.watchdownloader.Activity_WatchScanList.java

/**
 * Resets the PCC connection to request access again and clears any existing display data.
 *//*from w w  w.j  av a 2 s  .c  o m*/
private void resetPcc() {
    //Release the old access if it exists
    if (releaseHandle != null) {
        releaseHandle.close();
    }

    //Reset the device list display
    bDevicesInList = false;
    deviceList_Display.clear();
    HashMap<String, String> listItem = new HashMap<String, String>();
    listItem.put("title", "No Devices Found");
    listItem.put("desc", "No results received from plugin yet...");
    deviceList_Display.add(listItem);
    adapter_deviceList_Display.notifyDataSetChanged();

    tv_status.setText("Connecting...");

    //Make the access request
    releaseHandle = AntPlusWatchDownloaderPcc.requestDeviceListAccess(this,
            new IPluginAccessResultReceiver<AntPlusWatchDownloaderPcc>() {
                @Override
                public void onResultReceived(AntPlusWatchDownloaderPcc result, RequestAccessResult resultCode,
                        DeviceState initialDeviceState) {
                    switch (resultCode) {
                    case SUCCESS:
                        watchPcc = result;
                        tv_status.setText(result.getDeviceName() + ": " + initialDeviceState);
                        watchPcc.requestCurrentDeviceList();
                        //subscribeToEvents();
                        break;
                    case CHANNEL_NOT_AVAILABLE:
                        Toast.makeText(Activity_WatchScanList.this, "Channel Not Available", Toast.LENGTH_SHORT)
                                .show();
                        tv_status.setText("Error. Do Menu->Reset.");
                        break;
                    case ADAPTER_NOT_DETECTED:
                        Toast.makeText(Activity_WatchScanList.this,
                                "ANT Adapter Not Available. Built-in ANT hardware or external adapter required.",
                                Toast.LENGTH_SHORT).show();
                        tv_status.setText("Error. Do Menu->Reset.");
                        break;
                    case BAD_PARAMS:
                        //Note: Since we compose all the params ourself, we should never see this result
                        Toast.makeText(Activity_WatchScanList.this, "Bad request parameters.",
                                Toast.LENGTH_SHORT).show();
                        tv_status.setText("Error. Do Menu->Reset.");
                        break;
                    case OTHER_FAILURE:
                        Toast.makeText(Activity_WatchScanList.this,
                                "RequestAccess failed. See logcat for details.", Toast.LENGTH_SHORT).show();
                        tv_status.setText("Error. Do Menu->Reset.");
                        break;
                    case DEPENDENCY_NOT_INSTALLED:
                        tv_status.setText("Error. Do Menu->Reset.");
                        AlertDialog.Builder adlgBldr = new AlertDialog.Builder(Activity_WatchScanList.this);
                        adlgBldr.setTitle("Missing Dependency");
                        adlgBldr.setMessage("The required service\n\""
                                + AntPlusWatchDownloaderPcc.getMissingDependencyName()
                                + "\"\n was not found. You need to install the ANT+ Plugins service or you may need to update your existing version if you already have it. Do you want to launch the Play Store to get it?");
                        adlgBldr.setCancelable(true);
                        adlgBldr.setPositiveButton("Go to Store", new OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                Intent startStore = null;
                                startStore = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="
                                        + AntPlusWatchDownloaderPcc.getMissingDependencyPackageName()));
                                startStore.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

                                Activity_WatchScanList.this.startActivity(startStore);
                            }
                        });
                        adlgBldr.setNegativeButton("Cancel", new OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        });

                        final AlertDialog waitDialog = adlgBldr.create();
                        waitDialog.show();
                        break;
                    case USER_CANCELLED:
                        tv_status.setText("Cancelled. Do Menu->Reset.");
                        break;
                    case UNRECOGNIZED:
                        Toast.makeText(Activity_WatchScanList.this,
                                "Failed: UNRECOGNIZED. PluginLib Upgrade Required?", Toast.LENGTH_SHORT).show();
                        tv_status.setText("Error. Do Menu->Reset.");
                        break;
                    default:
                        Toast.makeText(Activity_WatchScanList.this, "Unrecognized result: " + resultCode,
                                Toast.LENGTH_SHORT).show();
                        tv_status.setText("Error. Do Menu->Reset.");
                        break;
                    }
                }
            },
            //Receives state changes and shows it on the status display line
            new IDeviceStateChangeReceiver() {
                @Override
                public void onDeviceStateChange(final DeviceState newDeviceState) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            tv_status.setText(watchPcc.getDeviceName() + ": " + newDeviceState);
                            if (newDeviceState == DeviceState.DEAD)
                                watchPcc = null;
                        }
                    });

                }
            },
            //Receives the device list updates and displays the current list
            new IAvailableDeviceListReceiver() {
                @Override
                public void onNewAvailableDeviceList(DeviceListUpdateCode listUpdateCode,
                        final DeviceInfo[] deviceInfos, DeviceInfo deviceChanging) {
                    switch (listUpdateCode) {
                    case NO_CHANGE:
                    case DEVICE_ADDED_TO_LIST:
                    case DEVICE_REMOVED_FROM_LIST:
                        // Note: This is for reference only and is not necessarily the optimal way to update.

                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                deviceList_Display.clear();

                                if (deviceInfos.length != 0) {
                                    deviceInfoArray = deviceInfos;
                                    bDevicesInList = true;
                                    for (int i = 0; i < deviceInfos.length; ++i) {
                                        HashMap<String, String> listItem = new HashMap<String, String>();
                                        listItem.put("title", deviceInfos[i].getDisplayName());
                                        listItem.put("desc",
                                                Integer.toString(deviceInfos[i].getAntfsDeviceType()));

                                        deviceList_Display.add(listItem);
                                    }
                                } else {
                                    bDevicesInList = false;
                                    HashMap<String, String> listItem = new HashMap<String, String>();
                                    listItem.put("title", "No Devices Found");
                                    listItem.put("desc", "No watches detected in range yet...");
                                    deviceList_Display.add(listItem);
                                }

                                adapter_deviceList_Display.notifyDataSetChanged();
                            }
                        });
                        break;

                    case UNRECOGNIZED:
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Toast.makeText(Activity_WatchScanList.this,
                                        "Failed: UNRECOGNIZED. PluginLib Upgrade Required?", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        });
                        break;
                    default: // Unknown code received
                        return;
                    }
                }
            });
}

From source file:com.example.drugsformarinemammals.Combined_Search.java

private void displayMessage(String messageTitle, String message) {
    AlertDialog.Builder myalert = new AlertDialog.Builder(this);

    TextView title = new TextView(this);
    title.setTypeface(Typeface.SANS_SERIF);
    title.setTextSize(20);/*  w  w w  .j  a  va 2 s . c o m*/
    title.setTextColor(getResources().getColor(R.color.blue));
    title.setPadding(8, 8, 8, 8);
    title.setText(messageTitle);
    title.setGravity(Gravity.CENTER_VERTICAL);

    LinearLayout layout = new LinearLayout(this);
    TextView text = new TextView(this);
    text.setTypeface(Typeface.SANS_SERIF);
    text.setTextSize(20);
    text.setPadding(10, 10, 10, 10);
    text.setText(message);
    layout.addView(text);

    myalert.setView(layout);
    myalert.setCustomTitle(title);
    myalert.setCancelable(true);
    myalert.show();

}

From source file:com.almunt.jgcaap.systemupdater.MainActivity.java

public void RebootRecovery(boolean update) {
    AlertDialog.Builder builder1 = new AlertDialog.Builder(MainActivity.this);
    builder1.setTitle("Recovery Reboot");
    if (update)/*from   ww w  . j  a  va2s .  c o m*/
        builder1.setMessage(
                "Would you like to reboot into recovery now to complete update?\nClear ORS will delete the OpenRecoveryScript to stop TWRP from automatically installing any files.");
    else
        builder1.setMessage("Would you like to reboot into recovery now.\n"
                + "Clear ORS will delete the current OpenRecoveryScript and stop any automatic update installations in TWRP");
    builder1.setCancelable(true);
    builder1.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            try {
                Process su = Runtime.getRuntime().exec("su");
                DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
                outputStream.writeBytes("reboot recovery\n");
                outputStream.flush();
                outputStream.writeBytes("exit\n");
                outputStream.flush();
                su.waitFor();
            } catch (IOException e) {
                Toast.makeText(MainActivity.this, "Error No Root Access detected", Toast.LENGTH_LONG).show();
            } catch (InterruptedException e) {
                Toast.makeText(MainActivity.this, "Error No Root Access detected", Toast.LENGTH_LONG).show();
            }
        }
    });
    builder1.setNeutralButton("Clear ORS", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            try {
                Process su = Runtime.getRuntime().exec("su");
                DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
                outputStream.writeBytes("cd /cache/recovery/\n");
                outputStream.flush();
                outputStream.writeBytes("rm openrecoveryscript\n");
                outputStream.flush();
                outputStream.writeBytes("exit\n");
                outputStream.flush();
                su.waitFor();
                Toast.makeText(MainActivity.this, "OpenRecoveryScript file was cleared", Toast.LENGTH_LONG)
                        .show();
            } catch (IOException e) {
                Toast.makeText(MainActivity.this, "Error No Root Access detected", Toast.LENGTH_LONG).show();
            } catch (InterruptedException e) {
                Toast.makeText(MainActivity.this, "Error No Root Access detected", Toast.LENGTH_LONG).show();
            }
        }
    });
    builder1.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
        }
    });
    if (update)
        builder1.setNegativeButton("Reboot Later", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
            }
        });

    AlertDialog alert11 = builder1.create();
    alert11.show();
}

From source file:com.gsma.rcs.ri.messaging.GroupTalkView.java

/**
 * Add participants to be invited in the session
 *///www .ja  v a2s.  c om
private void addParticipants() {
    /* Build list of available contacts not already in the conference */
    Set<ContactId> availableParticipants = new HashSet<>();
    try {
        Set<RcsContact> contacts = getContactApi().getRcsContacts();
        for (RcsContact rcsContact : contacts) {
            ContactId contact = rcsContact.getContactId();
            if (mGroupChat.isAllowedToInviteParticipant(contact)) {
                availableParticipants.add(contact);
            }
        }
    } catch (RcsServiceException e) {
        showException(e);
        return;
    }
    /* Check if some participants are available */
    if (availableParticipants.size() == 0) {
        showMessage(R.string.label_no_participant_found);
        return;
    }
    /* Display contacts */
    final List<String> selectedParticipants = new ArrayList<>();
    final CharSequence[] items = new CharSequence[availableParticipants.size()];
    int i = 0;
    for (ContactId contact : availableParticipants) {
        items[i++] = contact.toString();
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.label_select_contacts);
    builder.setCancelable(true);
    builder.setMultiChoiceItems(items, null, new DialogInterface.OnMultiChoiceClickListener() {
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            String c = (String) items[which];
            if (isChecked) {
                selectedParticipants.add(c);
            } else {
                selectedParticipants.remove(c);
            }
        }
    });
    builder.setNegativeButton(R.string.label_cancel, null);
    builder.setPositiveButton(R.string.label_ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int position) {
            /* Add new participants in the session in background */
            try {
                int max = mGroupChat.getMaxParticipants() - 1;
                int connected = mGroupChat.getParticipants().size();
                int limit = max - connected;
                if (selectedParticipants.size() > limit) {
                    showMessage(R.string.label_max_participants);
                    return;
                }
                Set<ContactId> contacts = new HashSet<>();
                ContactUtil contactUtils = ContactUtil.getInstance(GroupTalkView.this);
                for (String participant : selectedParticipants) {
                    contacts.add(contactUtils.formatContact(participant));
                }
                /* Add participants */
                mGroupChat.inviteParticipants(contacts);

            } catch (RcsServiceException e) {
                showException(e);
            }
        }
    });
    registerDialog(builder.show());
}

From source file:com.orangelabs.rcs.ri.extension.messaging.MessagingSessionView.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
        if (mSession != null) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(getString(R.string.label_confirm_close));
            builder.setPositiveButton(getString(R.string.label_ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // Quit the session
                    quitSession();//www. j  a  va2 s  . c  o m
                }
            });
            builder.setNegativeButton(getString(R.string.label_cancel), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // Exit activity
                    finish();
                }
            });
            builder.setCancelable(true);
            builder.show();
        } else {
            // Exit activity
            finish();
        }
        return true;
    }

    return super.onKeyDown(keyCode, event);
}

From source file:org.xbmc.android.remote.presentation.controller.AbstractController.java

public void onError(Exception exception) {
    if (mActivity == null) {
        return;/*from   w w w  .  jav  a2 s.  c  om*/
    }
    final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    try {
        throw exception;
    } catch (NoSettingsException e) {
        builder.setTitle("No hosts detected");
        builder.setMessage(e.getMessage());
        builder.setNeutralButton("Settings", new OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                final Intent intent = new Intent(mActivity, HostSettingsActivity.class);
                //               intent.putExtra(SettingsActivity.JUMP_TO, SettingsActivity.JUMP_TO_INSTANCES);
                mActivity.startActivity(intent);
                mDialogShowing = false;
            }
        });
    } catch (NoNetworkException e) {
        builder.setTitle("No Network");
        builder.setMessage(e.getMessage());
        builder.setCancelable(true);
        builder.setNeutralButton("Settings", new OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                mActivity.startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
                mDialogShowing = false;
            }
        });
    } catch (WrongDataFormatException e) {
        builder.setTitle("Internal Error");
        builder.setMessage(
                "Wrong data from HTTP API; expected '" + e.getExpected() + "', got '" + e.getReceived() + "'.");
    } catch (SocketTimeoutException e) {
        builder.setTitle("Socket Timeout");
        builder.setMessage("Make sure XBMC webserver is enabled and XBMC is running.");
        builder.setNeutralButton("Settings", new OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                mActivity.startActivity(new Intent(mActivity, SettingsActivity.class));
                mDialogShowing = false;
            }
        });
    } catch (ConnectException e) {
        builder.setTitle("Connection Refused");
        builder.setMessage("Make sure XBMC webserver is enabled and XBMC is running.");
        builder.setNeutralButton("Settings", new OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                mActivity.startActivity(new Intent(mActivity, SettingsActivity.class));
                mDialogShowing = false;
            }
        });
    } catch (IOException e) {
        if (e.getMessage() != null && e.getMessage().startsWith("Network unreachable")) {
            builder.setTitle("No network");
            builder.setMessage(
                    "XBMC Remote needs local network access. Please make sure that your wireless network is activated. You can click on the Settings button below to directly access your network settings.");
            builder.setNeutralButton("Settings", new OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    mActivity.startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
                    mDialogShowing = false;
                }
            });
        } else {
            builder.setTitle("I/O Exception (" + e.getClass().getCanonicalName() + ")");
            if (e.getMessage() != null) {
                builder.setMessage(e.getMessage().toString());
            }
            Log.e(TAG, e.getStackTrace().toString());
        }
    } catch (HttpException e) {
        if (e.getMessage().startsWith("401")) {
            builder.setTitle("HTTP 401: Unauthorized");
            builder.setMessage(
                    "The supplied username and/or password is incorrect. Please check your settings.");
            builder.setNeutralButton("Settings", new OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    mActivity.startActivity(new Intent(mActivity, SettingsActivity.class));
                    mDialogShowing = false;
                }
            });
        }
    } catch (Exception e) {
        final String name = e.getClass().getName();
        builder.setTitle(name.substring(name.lastIndexOf(".") + 1));
        builder.setMessage(e.getMessage());
    } finally {

        exception.printStackTrace();
    }
    showDialog(builder);
}