Example usage for java.lang Thread setDefaultUncaughtExceptionHandler

List of usage examples for java.lang Thread setDefaultUncaughtExceptionHandler

Introduction

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

Prototype

public static void setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler eh) 

Source Link

Document

Set the default handler invoked when a thread abruptly terminates due to an uncaught exception, and no other handler has been defined for that thread.

Usage

From source file:me.mast3rplan.phantombot.cache.UsernameCache.java

private UsernameCache() {
    Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance());
}

From source file:at.wada811.dayscounter.view.activity.TutorialActivity.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override/*  w w w  .j av  a2s .  c  o m*/
protected void onCreate(Bundle savedInstanceState) {
    // catch UncaughtException
    Thread.setDefaultUncaughtExceptionHandler(new CrashExceptionHandler(getApplicationContext()));
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tutorial);
    // Window size dialog
    WindowManager.LayoutParams params = getWindow().getAttributes();
    params.width = WindowManager.LayoutParams.MATCH_PARENT;
    params.height = WindowManager.LayoutParams.MATCH_PARENT;
    getWindow().setAttributes(params);
    // Title
    setTitle(getString(R.string.app_name) + " " + ApplicationUtils.getVersionName(this));
    // check Crash report
    File file = ResourceUtils.getFile(this, CrashExceptionHandler.FILE_NAME);
    if (file.exists()) {
        startActivity(new Intent(this, CrashReportActivity.class));
        finish();
        return;
    }
    // Tutorial
    ImageView how2use = (ImageView) findViewById(R.id.how2use);
    how2use.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = IntentUtils.createOpenBrowserIntent(getString(R.string.YouTubeURL));
            startActivity(intent);
        }
    });
    Button reportProblem = (Button) findViewById(R.id.reportProblem);
    reportProblem.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            reportProblem();
        }
    });
    Button rateThisApp = (Button) findViewById(R.id.rateThisApp);
    rateThisApp.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            rateThisApp();
        }
    });
}

From source file:com.spotify.helios.system.AgentStateDirConflictTest.java

@Before
public void setup() throws Exception {
    zk = new ZooKeeperTestingServerManager();
    dueh = Thread.getDefaultUncaughtExceptionHandler();

    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        @Override//ww  w.  j a v a 2  s .  com
        public void uncaughtException(final Thread t, final Throwable e) {
        }
    });

    stateDir = Files.createTempDirectory("helios-agent-conflict-test");

    first = makeAgent("first");
    second = makeAgent("second");
}

From source file:me.gloriouseggroll.quorrabot.script.Script.java

@SuppressWarnings("CallToThreadStartDuringObjectConstruction")
public Script(File file) {
    //this.fileWatcher = new ScriptFileWatcher(this);
    this.file = file;

    Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance());

    //new Thread(fileWatcher).start();
}

From source file:org.metasyntactic.utilities.ExceptionUtilities.java

public static void registerExceptionHandler(Context context) {
    PackageManager pm = context.getPackageManager();
    try {//from  ww  w  .j a  va 2s . c  o m
        PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
        Version = pi.versionName;
        Package = pi.packageName;
        FilesPath = context.getFilesDir().getAbsolutePath();
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    new Thread() {
        @Override
        public void run() {
            submitStackTraces();
            Thread.setDefaultUncaughtExceptionHandler(DEFAULT_EXCEPTION_HANDLER);
        }
    }.start();
}

From source file:org.akvo.flow.service.TimeCheckService.java

@Override
protected void onHandleIntent(Intent intent) {
    Thread.setDefaultUncaughtExceptionHandler(PersistentUncaughtExceptionHandler.getInstance());
    checkTime();
}

From source file:Main.java

/**
 * Have shutdown actually means shutdown. Tasks that need to complete should use
 * futures./*from   w  w w . j av a2 s  .c o m*/
 */
public static ScheduledThreadPoolExecutor getScheduledThreadPoolExecutor(String name,
        UncaughtExceptionHandler handler, int poolSize, int stackSize) {
    // HACK: ScheduledThreadPoolExecutor won't let use the handler so
    // if we're using ExceptionHandlingRunnable then we'll be able to 
    // pick up the exceptions
    Thread.setDefaultUncaughtExceptionHandler(handler);

    ThreadFactory factory = getThreadFactory(name, handler);
    ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(poolSize, factory);
    executor.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
    executor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
    return executor;
}

From source file:tv.phantombot.script.ScriptEventManager.java

private ScriptEventManager() {
    Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance());

    Reflections reflections = new Reflections("tv.phantombot.event");
    Set<Class<? extends Event>> classes = reflections.getSubTypesOf(Event.class);

    for (Class<? extends Event> c : classes) {
        this.classes.add(c.getName().substring(0, c.getName().lastIndexOf(".")));
    }/*from   w ww . j  a v a 2s.c  om*/
}

From source file:com.lewen.listener.vlc.Util.java

public static LibVLC getLibVlcInstance() throws LibVlcException {
    LibVLC instance = LibVLC.getExistingInstance();
    if (instance == null) {
        Thread.setDefaultUncaughtExceptionHandler(new VlcCrashHandler());

        instance = LibVLC.getInstance();
        Context context = TBApplication.App;
        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
        updateLibVlcSettings(pref);//from  w w  w.  j a v a 2 s. c o  m
        instance.init(context);
    }
    return instance;
}

From source file:com.github.dozermapper.core.DozerBeanMapperTest.java

@Before
public void setUp() {
    // todo the test should be redesigned once DozerBeanMapper is immutable #434
    mapper = DozerBeanMapperBuilder.buildDefault();
    exceptions = new ArrayList<>();
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(Thread t, Throwable e) {
            exceptions.add(e);//from  ww  w.  j  ava 2s.c  o  m
        }
    });
}