List of usage examples for java.lang Thread setDefaultUncaughtExceptionHandler
public static void setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler eh)
From source file:com.scaniatv.TipeeeStreamAPIv1.java
private TipeeeStreamAPIv1() { Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance()); }
From source file:org.andicar.service.UpdateCheckService.java
@Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); if (getSharedPreferences(StaticValues.GLOBAL_PREFERENCE_NAME, Context.MODE_MULTI_PROCESS) .getBoolean("SendCrashReport", true)) Thread.setDefaultUncaughtExceptionHandler( new AndiCarExceptionHandler(Thread.getDefaultUncaughtExceptionHandler(), this)); try {/*from w ww . j a v a 2 s . c o m*/ Bundle extras = intent.getExtras(); if (extras == null || extras.getBoolean("setJustNextRun") || !extras.getBoolean("AutoUpdateCheck")) { setNextRun(); stopSelf(); } URL updateURL = new URL(StaticValues.VERSION_FILE_URL); URLConnection conn = updateURL.openConnection(); if (conn == null) return; InputStream is = conn.getInputStream(); if (is == null) return; BufferedInputStream bis = new BufferedInputStream(is); ByteArrayBuffer baf = new ByteArrayBuffer(50); int current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); } /* Convert the Bytes read to a String. */ String s = new String(baf.toByteArray()); /* Get current Version Number */ int curVersion = getPackageManager().getPackageInfo("org.andicar.activity", 0).versionCode; int newVersion = Integer.valueOf(s); /* Is a higher version than the current already out? */ if (newVersion > curVersion) { //get the whats new message updateURL = new URL(StaticValues.WHATS_NEW_FILE_URL); conn = updateURL.openConnection(); if (conn == null) return; is = conn.getInputStream(); if (is == null) return; bis = new BufferedInputStream(is); baf = new ByteArrayBuffer(50); current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); } /* Convert the Bytes read to a String. */ s = new String(baf.toByteArray()); mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notification = null; Intent i = new Intent(this, WhatsNewDialog.class); i.putExtra("UpdateMsg", s); PendingIntent contentIntent = PendingIntent.getActivity(UpdateCheckService.this, 0, i, 0); CharSequence title = getText(R.string.Notif_UpdateTitle); String message = getString(R.string.Notif_UpdateMsg); notification = new Notification(R.drawable.icon_sys_info, message, System.currentTimeMillis()); notification.flags |= Notification.DEFAULT_LIGHTS; notification.flags |= Notification.DEFAULT_SOUND; notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.setLatestEventInfo(UpdateCheckService.this, title, message, contentIntent); mNM.notify(StaticValues.NOTIF_UPDATECHECK_ID, notification); setNextRun(); } stopSelf(); } catch (Exception e) { Log.i("UpdateService", "Service failed."); e.printStackTrace(); } }
From source file:com.yamin.kk.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 = VLCApplication.getAppContext(); SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); updateLibVlcSettings(pref);/*w w w . j ava2s . c o m*/ instance.init(context); } return instance; }
From source file:com.gmt2001.YouTubeAPIv3.java
private YouTubeAPIv3() { Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance()); }
From source file:com.illusionaryone.GoogleURLShortenerAPIv1.java
private GoogleURLShortenerAPIv1() { Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance()); }
From source file:com.illusionaryone.FrankerZAPIv1.java
private FrankerZAPIv1() { Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance()); }
From source file:org.apache.pulsar.PulsarBrokerStarter.java
public static void main(String[] args) throws Exception { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss,SSS"); Thread.setDefaultUncaughtExceptionHandler((thread, exception) -> { System.out.println(String.format("%s [%s] error Uncaught exception in thread %s: %s", dateFormat.format(new Date()), thread.getContextClassLoader(), thread.getName(), exception.getMessage())); });//from w ww. j a va 2 s . c o m BrokerStarter starter = new BrokerStarter(args); Runtime.getRuntime().addShutdownHook(new Thread(() -> { starter.shutdown(); })); try { starter.start(); } catch (Exception e) { log.error("Failed to start pulsar service.", e); Runtime.getRuntime().halt(1); } starter.join(); }
From source file:com.illusionaryone.TwitchAlertsAPIv1.java
private TwitchAlertsAPIv1() { Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance()); }
From source file:com.gmt2001.TwitchAPIv3.java
private TwitchAPIv3() { Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance()); }
From source file:com.illusionaryone.StreamTipAPI.java
private StreamTipAPI() { Thread.setDefaultUncaughtExceptionHandler(com.gmt2001.UncaughtExceptionHandler.instance()); }