Example usage for java.lang Thread getDefaultUncaughtExceptionHandler

List of usage examples for java.lang Thread getDefaultUncaughtExceptionHandler

Introduction

In this page you can find the example usage for java.lang Thread getDefaultUncaughtExceptionHandler.

Prototype

public static UncaughtExceptionHandler getDefaultUncaughtExceptionHandler() 

Source Link

Document

Returns the default handler invoked when a thread abruptly terminates due to an uncaught exception.

Usage

From source file:it.mb.whatshare.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Utils.checkDebug(this);
    analytics = GoogleAnalytics.getInstance(this);
    tracker = analytics.getTracker(getResources().getString(R.string.ga_trackingId));

    Thread.UncaughtExceptionHandler uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
    if (uncaughtExceptionHandler instanceof ExceptionReporter) {
        ExceptionReporter exceptionReporter = (ExceptionReporter) uncaughtExceptionHandler;
        exceptionReporter.setExceptionParser(new AnalyticsExceptionParser());
    }// w w  w.j  a  v  a 2  s . c  o m

    analytics.setDefaultTracker(tracker);
    // start the registration process if needed
    GCMIntentService.registerWithGCM(this);
    View menu = getLayoutInflater().inflate(R.layout.menu, null);
    setContentView(menu);
}

From source file:org.adblockplus.android.ProxyService.java

private void passProxySettings(String proxyHost, String proxyPort, String proxyExcl) {
    try {/*from   w  w  w . java2s  . c om*/
        CrashHandler handler = (CrashHandler) Thread.getDefaultUncaughtExceptionHandler();
        handler.saveProxySettings(proxyHost, proxyPort, proxyExcl);
    } catch (ClassCastException e) {
        // ignore - default handler in use
    }
}

From source file:com.dragoniade.deviantart.favorites.FavoritesDownloader.java

private String getDocumentUrl(Deviation da, AtomicBoolean download) {
    String downloadUrl = da.getDocumentDownloadUrl();
    GetMethod method = new GetMethod(downloadUrl);

    try {//from  w  ww .  j  a  v  a2s .co  m
        int sc = -1;
        do {
            method.setFollowRedirects(false);
            sc = client.executeMethod(method);
            requestCount++;

            if (sc >= 300 && sc <= 399) {
                String location = method.getResponseHeader("Location").getValue();
                method.releaseConnection();
                return location;
            } else {
                LoggableException ex = new LoggableException(method.getResponseBodyAsString());
                Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), ex);

                int res = showConfirmDialog(owner,
                        "An error has occured when contacting deviantART : error " + sc + ". Try again?",
                        "Continue?", JOptionPane.YES_NO_CANCEL_OPTION);
                if (res == JOptionPane.NO_OPTION) {
                    String text = "<br/><a style=\"color:red;\" href=\"" + da.getUrl() + "\">" + downloadUrl
                            + " has an error" + "</a>";
                    setPaneText(text);
                    method.releaseConnection();
                    progress.incremTotal();
                    download.set(false);
                    return null;
                }
                if (res == JOptionPane.CANCEL_OPTION) {
                    return null;
                }
            }
        } while (true);
    } catch (HttpException e) {
        showMessageDialog(owner, "Error contacting deviantART: " + e.getMessage(), "Error",
                JOptionPane.ERROR_MESSAGE);
        return null;
    } catch (IOException e) {
        showMessageDialog(owner, "Error contacting deviantART: " + e.getMessage(), "Error",
                JOptionPane.ERROR_MESSAGE);
        return null;
    }
}

From source file:com.github.vatbub.tictactoe.view.Main.java

@FXML
// This method is called by the FXMLLoader when initialization is complete
void initialize() {
    // modify the default exception handler to show a good error message on every uncaught exception
    final Thread.UncaughtExceptionHandler currentUncaughtExceptionHandler = Thread
            .getDefaultUncaughtExceptionHandler();
    Thread.setDefaultUncaughtExceptionHandler((thread, exception) -> {
        if (currentUncaughtExceptionHandler != null) {
            // execute current handler as we only want to append it
            currentUncaughtExceptionHandler.uncaughtException(thread, exception);
        }/*  w w w.j av  a  2s  .co  m*/
        Platform.runLater(() -> new ExceptionAlert(exception).showAndWait());
    });

    opponentsTurnHBox.heightProperty()
            .addListener((observable, oldValue, newValue) -> updateOpponentsTurnHBox(false));

    aiLevelLabelClipRectangle = new Rectangle(0, 0, 0, 0);
    aiLevelLabelClipRectangle.setEffect(new MotionBlur(0, 10));
    aiLevelLabelPane.setClip(aiLevelLabelClipRectangle);
    aiLevelLabelClipRectangle.heightProperty().bind(aiLevelLabelPane.heightProperty());
    aiLevelLabelPane.widthProperty().addListener((observable, oldValue, newValue) -> updateAILevelLabel(true));

    Rectangle menuSubBoxClipRectangle = new Rectangle(0, 0, 0, 0);
    menuSubBox.setClip(menuSubBoxClipRectangle);
    menuSubBoxClipRectangle.heightProperty().bind(menuSubBox.heightProperty());
    menuSubBoxClipRectangle.widthProperty().bind(menuSubBox.widthProperty());

    Rectangle playOnlineClipRectangle = new Rectangle(0, 0, 0, 0);
    playOnlineClipAnchorPane.setClip(playOnlineClipRectangle);
    playOnlineClipRectangle.heightProperty().bind(playOnlineClipAnchorPane.heightProperty());
    playOnlineClipRectangle.widthProperty().bind(playOnlineClipAnchorPane.widthProperty());

    player1SetSampleName();
    player2SetSampleName();

    gameTable.heightProperty()
            .addListener((observable, oldValue, newValue) -> refreshedNodes.refreshAll(gameTable.getWidth(),
                    oldValue.doubleValue(), gameTable.getWidth(), newValue.doubleValue()));
    gameTable.widthProperty()
            .addListener((observable, oldValue, newValue) -> refreshedNodes.refreshAll(oldValue.doubleValue(),
                    gameTable.getHeight(), newValue.doubleValue(), gameTable.getHeight()));

    player1AIToggle.selectedProperty().addListener((observable, oldValue, newValue) -> {
        showHideAILevelSlider(newValue, player2AIToggle.isSelected());
        player1SetSampleName();
    });
    player2AIToggle.selectedProperty().addListener((observable, oldValue, newValue) -> {
        showHideAILevelSlider(player1AIToggle.isSelected(), newValue);
        player2SetSampleName();
    });

    gameTable.setSelectionModel(null);
    gameTable.heightProperty().addListener((observable, oldValue, newValue) -> {
        Pane header = (Pane) gameTable.lookup("TableHeaderRow");
        if (header.isVisible()) {
            header.setMaxHeight(0);
            header.setMinHeight(0);
            header.setPrefHeight(0);
            header.setVisible(false);
        }
        renderRows();
    });
    gameTable.setRowFactory(param -> {
        TableRow<Row> row = new TableRow<>();
        row.styleProperty().bind(style);

        if (rowFont == null) {
            rowFont = new SimpleObjectProperty<>();
            rowFont.bind(row.fontProperty());
        }

        return row;
    });

    looseImage.fitHeightProperty().bind(looserPane.heightProperty());
    looseImage.fitWidthProperty().bind(looserPane.widthProperty());
    looseImage.fitHeightProperty().addListener((observable, oldValue, newValue) -> reloadImage(looseImage,
            getClass().getResource("loose.png").toString(), looseImage.getFitWidth(), newValue.doubleValue()));
    looseImage.fitWidthProperty().addListener((observable, oldValue, newValue) -> reloadImage(looseImage,
            getClass().getResource("loose.png").toString(), newValue.doubleValue(), looseImage.getFitWidth()));

    confetti.fitHeightProperty().bind(winPane.heightProperty());
    confetti.fitWidthProperty().bind(winPane.widthProperty());
    confetti.fitHeightProperty().addListener((observable, oldValue, newValue) -> reloadImage(confetti,
            getClass().getResource("confetti.png").toString(), confetti.getFitWidth(), newValue.doubleValue()));
    confetti.fitWidthProperty().addListener((observable, oldValue, newValue) -> reloadImage(confetti,
            getClass().getResource("confetti.png").toString(), newValue.doubleValue(), confetti.getFitWidth()));

    aiLevelSlider.valueProperty().addListener((observable, oldValue, newValue) -> updateAILevelLabel());

    playOnlineHyperlink.widthProperty().addListener((observable, oldValue, newValue) -> {
        if (playOnlineAnchorPane.isVisible()) {
            setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true);
        }
    });
    playOnlineHyperlink.heightProperty().addListener((observable, oldValue, newValue) -> {
        if (playOnlineAnchorPane.isVisible()) {
            setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true);
        }
    });
    playOnlineHyperlink.textProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue.equals(oldValue)) {
            if (newValue.contains("ff")) {
                setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true, 1);
            } else {
                setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true, -1);
            }
        }
    });

    // Kunami code
    root.setOnKeyPressed(event -> {
        if (KunamiCode.isCompleted(event.getCode())) {
            if (root.getEffect() != null && root.getEffect() instanceof Blend) {
                BlendMode currentMode = ((Blend) root.getEffect()).getMode();
                BlendMode nextMode;
                if (currentMode == BlendMode.values()[BlendMode.values().length - 1]) {
                    nextMode = BlendMode.values()[0];
                } else {
                    nextMode = BlendMode.values()[Arrays.asList(BlendMode.values()).indexOf(currentMode) + 1];
                }
                ((Blend) root.getEffect()).setMode(nextMode);
            } else {
                root.setEffect(new Blend(BlendMode.EXCLUSION));
            }
        }
    });

    // prompt text of the my username field in the online multiplayer menu
    onlineMyUsername.promptTextProperty().bind(player1Name.promptTextProperty());
    onlineMyUsername.textProperty().bindBidirectional(player1Name.textProperty());

    setAccessibleTextsForNodesThatDoNotChange();
    updateAccessibleTexts();

    initBoard();
    initNewGame();
}

From source file:net.sourceforge.kalimbaradio.androidapp.util.Util.java

public static void setUncaughtExceptionHandler(Context context) {
    Thread.UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler();
    if (!(handler instanceof SubsonicUncaughtExceptionHandler)) {
        Thread.setDefaultUncaughtExceptionHandler(new SubsonicUncaughtExceptionHandler(context));
    }//  w  w w .j  a v  a 2s. c o  m
}

From source file:view.EditorView.java

@FXML
// This method is called by the FXMLLoader when initialization is complete
void initialize() {
    assert insertRoom != null : "fx:id=\"insertRoom\" was not injected: check your FXML file 'EditorMain.fxml'.";
    assert drawing != null : "fx:id=\"drawing\" was not injected: check your FXML file 'EditorMain.fxml'.";
    assert insertPath != null : "fx:id=\"insertPath\" was not injected: check your FXML file 'EditorMain.fxml'.";

    currentEditorInstance = this;

    // modify the default exception handler to show the ReportingDialog on every uncaught exception
    final Thread.UncaughtExceptionHandler currentUncaughtExceptionHandler = Thread
            .getDefaultUncaughtExceptionHandler();
    Thread.setDefaultUncaughtExceptionHandler((thread, exception) -> {
        if (currentUncaughtExceptionHandler != null) {
            // execute current handler as we only want to append it
            currentUncaughtExceptionHandler.uncaughtException(thread, exception);
        }//  w w w  .ja  v  a  2s .  c o m
        Platform.runLater(() -> {
            new ExceptionAlert(exception).showAndWait();
            new ReportingDialog(stage.getScene()).show(AppConfig.gitHubUserName, AppConfig.gitHubRepoName,
                    exception);
        });
    });

    currentGame.addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            newValue.modifiedProperty().addListener((observable1, oldValue1, newValue1) -> {
                this.menuItemSave.setDisable(!newValue1);
                setWindowTitle(newValue);
            });
        }
        setWindowTitle(newValue);
    });

    initGame();

    scrollPane.hvalueProperty().addListener((observable, oldValue, newValue) -> unselectingDisabled = true);
    scrollPane.vvalueProperty().addListener((observable, oldValue, newValue) -> unselectingDisabled = true);

    // add button icons
    insertRoom.setGraphic(new ImageView(new Image(EditorView.class.getResourceAsStream("add-room.png"))));
    moveButton.setGraphic(new ImageView(new Image(EditorView.class.getResourceAsStream("move-arrows.png"))));
    insertPath.setGraphic(
            new ImageView(new Image(EditorView.class.getResourceAsStream("connecting-points.png"))));
    autoLayoutButton
            .setGraphic(new ImageView(new Image(EditorView.class.getResourceAsStream("autoLayout.png"))));
    refreshViewButton
            .setGraphic(new ImageView(new Image(EditorView.class.getResourceAsStream("refreshView.png"))));

    // add tooltips
    insertRoom.setTooltip(new Tooltip("Insert a new room"));
    moveButton.setTooltip(new Tooltip("Move rooms"));
    insertPath.setTooltip(new Tooltip("Connect rooms to create walk paths"));
    autoLayoutButton.setTooltip(new Tooltip("Automatically rearrange the rooms in the view below"));
    refreshViewButton.setTooltip(new Tooltip("Refresh the current view"));

    // forward events to all selected items
    // drawing.setOnMouseClicked(forwardEventsToSelectableNodesHandler);
    // drawing.setOnMousePressed(forwardEventsToSelectableNodesHandler);
    // drawing.setOnMouseReleased(forwardEventsToSelectableNodesHandler);
    // drawing.setOnDragDetected(forwardEventsToSelectableNodesHandler);
    // drawing.setOnMouseDragged(forwardEventsToSelectableNodesHandler);
    scrollPane.setOnKeyPressed(event -> {
        if (event.getCode().equals(KeyCode.DELETE)) {
            for (Node child : new ArrayList<>(drawing.getChildren())) {
                if (child instanceof Disposable) {
                    if (((Disposable) child).isSelected() && event.getTarget() != child) {
                        FOKLogger.fine(EditorView.class.getName(),
                                "Sending disposal command to child, Child is:  " + child.toString()
                                        + "\ntarget is: " + event.getTarget().toString());
                        try {
                            ((Disposable) child).dispose();
                        } catch (IllegalStateException e) {
                            FOKLogger.log(EditorView.class.getName(), Level.INFO,
                                    "User tried to remove the current room (not allowed)", e);
                            new Alert(Alert.AlertType.ERROR, "Could not perform delete operation: \n\n"
                                    + ExceptionUtils.getRootCauseMessage(e)).show();
                        }
                    }
                }
            }
        } else if (event.getCode().equals(KeyCode.A) && event.isControlDown()) {
            // select everything
            for (Node child : new ArrayList<>(drawing.getChildren())) {
                if (child instanceof Selectable) {
                    ((Selectable) child).setSelected(true);
                }
            }
        }
    });
}

From source file:org.apache.hadoop.hive.llap.daemon.impl.TaskExecutorService.java

private void addToPreemptionQueue(TaskWrapper taskWrapper) {
    synchronized (lock) {
        boolean added = preemptionQueue.offer(taskWrapper);
        if (!added) {
            LOG.warn("Failed to add element {} to preemption queue. Terminating", taskWrapper);
            Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(),
                    new IllegalStateException("Preemption queue full. Cannot proceed"));
        }/*  ww  w.  j av  a  2s.c  om*/
        taskWrapper.setIsInPreemptableQueue(true);
        if (metrics != null) {
            metrics.setExecutorNumPreemptableRequests(preemptionQueue.size());
        }
    }
}

From source file:org.spontaneous.trackservice.RemoteService.java

private void registerExceptionHandler() {
    if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) {
        Thread.setDefaultUncaughtExceptionHandler(
                new CustomExceptionHandler(getExternalCacheDir().toString(), null));
    }/*from   w  ww  .  j a v  a2  s  . com*/
}

From source file:com.vonglasow.michael.satstat.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    defaultUEH = Thread.getDefaultUncaughtExceptionHandler();

    Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
        public void uncaughtException(Thread t, Throwable e) {
            Context c = getApplicationContext();
            File dumpDir = c.getExternalFilesDir(null);
            File dumpFile = new File(dumpDir, "satstat-" + System.currentTimeMillis() + ".log");
            PrintStream s;//from   w w w .j a v a  2s  .c o m
            try {
                InputStream buildInStream = getResources().openRawResource(R.raw.build);
                s = new PrintStream(dumpFile);
                s.append("SatStat build: ");

                int i;
                try {
                    i = buildInStream.read();
                    while (i != -1) {
                        s.write(i);
                        i = buildInStream.read();
                    }
                    buildInStream.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }

                s.append("\n\n");
                e.printStackTrace(s);
                s.flush();
                s.close();
            } catch (FileNotFoundException e2) {
                e2.printStackTrace();
            }
            defaultUEH.uncaughtException(t, e);
        }
    });

    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mSharedPreferences.registerOnSharedPreferenceChangeListener(this);

    final ActionBar actionBar = getActionBar();

    setContentView(R.layout.activity_main);

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Find out default screen orientation
    Configuration config = getResources().getConfiguration();
    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    int rot = wm.getDefaultDisplay().getRotation();
    isWideScreen = (config.orientation == Configuration.ORIENTATION_LANDSCAPE
            && (rot == Surface.ROTATION_0 || rot == Surface.ROTATION_180)
            || config.orientation == Configuration.ORIENTATION_PORTRAIT
                    && (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270));
    Log.d("MainActivity", "isWideScreen=" + Boolean.toString(isWideScreen));

    // compact action bar
    int dpX = (int) (this.getResources().getDisplayMetrics().widthPixels
            / this.getResources().getDisplayMetrics().density);
    /*
     * This is a crude way to ensure a one-line action bar with tabs
     * (not a drop-down list) and home (incon) and title only if there
     * is space, depending on screen width:
     * divide screen in units of 64 dp
     * each tab requires 1 unit, home and menu require slightly less,
     * title takes up approx. 2.5 units in portrait,
     * home and title are about 2 units wide in landscape
     */
    if (dpX < 192) {
        // just enough space for drop-down list and menu
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowTitleEnabled(false);
    } else if (dpX < 320) {
        // not enough space for four tabs, but home will fit next to list
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
    } else if (dpX < 384) {
        // just enough space for four tabs
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowTitleEnabled(false);
    } else if ((dpX < 448) || ((config.orientation == Configuration.ORIENTATION_PORTRAIT) && (dpX < 544))) {
        // space for four tabs and home, but not title
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
    } else {
        // ample space for home, title and all four tabs
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setDisplayShowTitleEnabled(true);
    }
    setEmbeddedTabs(actionBar, true);

    providerLocations = new HashMap<String, Location>();

    mAvailableProviderStyles = new ArrayList<String>(Arrays.asList(LOCATION_PROVIDER_STYLES));

    providerStyles = new HashMap<String, String>();
    providerAppliedStyles = new HashMap<String, String>();

    providerInvalidationHandler = new Handler();
    providerInvalidators = new HashMap<String, Runnable>();

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(this);

    // Add tabs, specifying the tab's text and TabListener
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        actionBar.addTab(actionBar.newTab()
                //.setText(mSectionsPagerAdapter.getPageTitle(i))
                .setIcon(mSectionsPagerAdapter.getPageIcon(i)).setTabListener(this));
    }

    // This is needed by the mapsforge library.
    AndroidGraphicFactory.createInstance(this.getApplication());

    // Get system services for event delivery
    mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    mOrSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
    mAccSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    mGyroSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
    mMagSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
    mLightSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
    mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
    mPressureSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE);
    mHumiditySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_RELATIVE_HUMIDITY);
    mTempSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_AMBIENT_TEMPERATURE);
    mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);

    mAccSensorRes = getSensorDecimals(mAccSensor, mAccSensorRes);
    mGyroSensorRes = getSensorDecimals(mGyroSensor, mGyroSensorRes);
    mMagSensorRes = getSensorDecimals(mMagSensor, mMagSensorRes);
    mLightSensorRes = getSensorDecimals(mLightSensor, mLightSensorRes);
    mProximitySensorRes = getSensorDecimals(mProximitySensor, mProximitySensorRes);
    mPressureSensorRes = getSensorDecimals(mPressureSensor, mPressureSensorRes);
    mHumiditySensorRes = getSensorDecimals(mHumiditySensor, mHumiditySensorRes);
    mTempSensorRes = getSensorDecimals(mTempSensor, mTempSensorRes);

    networkTimehandler = new Handler();
    networkTimeRunnable = new Runnable() {
        @Override
        public void run() {
            int newNetworkType = mTelephonyManager.getNetworkType();
            if (getNetworkGeneration(newNetworkType) != mLastNetworkGen)
                onNetworkTypeChanged(newNetworkType);
            else
                networkTimehandler.postDelayed(this, NETWORK_REFRESH_DELAY);
        }
    };

    wifiTimehandler = new Handler();
    wifiTimeRunnable = new Runnable() {

        @Override
        public void run() {
            mWifiManager.startScan();
            wifiTimehandler.postDelayed(this, WIFI_REFRESH_DELAY);
        }
    };

    updateLocationProviderStyles();
}

From source file:github.popeen.dsub.activity.SubsonicActivity.java

private void setUncaughtExceptionHandler() {
    Thread.UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler();
    if (!(handler instanceof SubsonicActivity.SubsonicUncaughtExceptionHandler)) {
        Thread.setDefaultUncaughtExceptionHandler(new SubsonicActivity.SubsonicUncaughtExceptionHandler(this));
    }//from w  ww .  ja v a 2 s  . c  o m
}