Java 8 Thread.UncaughtExceptionHandler - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Thread.UncaughtExceptionHandler class.

This code example shows how to use the following methods:uncaughtException
 
			//debug(e); 
			warn("reporting", Log.getStackTraceString(e));
			 
			if(eh != null){
				eh.uncaughtException(Thread.currentThread(), e);
			} 
			 
		}catch(Exception ex){
			ex.printStackTrace();
		} 
		 
	} 
	 
	private static UncaughtExceptionHandler eh;
	public static void setExceptionHandler(UncaughtExceptionHandler handler){
		eh = handler;
	} 
	 
	private static Map<String, Long> times = new HashMap<String, Long>();
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:sleep, uncaughtException
*/ 
    @Override 
    public void uncaughtException(Thread thread, Throwable ex) {
        if (!handleException(ex) && mDefaultHandler != null) {
            //如果用户没有处理则让系统默认的异常处理器来处理 
            mDefaultHandler.uncaughtException(thread, ex);
        } else { 
            try { 
                Thread.sleep(1000);
            } catch (InterruptedException e) {
               AdViewUtil.logError("", e);
            } 
             
            mDefaultHandler.uncaughtException(thread, ex);
             
            //退出程序 
//            android.os.Process.killProcess(android.os.Process.myPid()); 
//            System.exit(1); 
        } 
    } 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:uncaughtException
			try { 
				reportException(thread, ex, null, false);
			} catch (Exception e) {
				Log.e(TAG, "Error while reporting exception", e);
			} 
			subject.uncaughtException(thread, ex);
		} 
 
	} 
 
	/** 
	 * Sends an error report. 
	 *  
	 * @param thread The thread where the exception occurred (e.g. {@link java.lang.Thread#currentThread()}) 
	 * @param ex The exception 
	 */ 
	public void reportException(Thread thread, Throwable ex) {
		reportException(thread, ex, null, true);
	} 
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:sleep, uncaughtException
		Thread.setDefaultUncaughtExceptionHandler(this);
	} 
	 
	public void uncaughtException(Thread thread, Throwable ex) {
		if (!handleException(ex) && defaultHandler != null)
			defaultHandler.uncaughtException(thread, ex);
		else { 
			try { 
				Thread.sleep(5000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block 
				Log.e(TAG, "error : ", e);   
			}    
		} 
		 
		//重新启动activity 
		Intent intent = new Intent(context, MainActivity.class); 
		intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); 
		context.startActivity(intent); 
		//等待activity初始化完毕 

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:uncaughtException
String sdcardPath = Environment.getExternalStorageDirectory().getPath();
        writeLog(stacktrace, sdcardPath + "/vlc_crash");
        writeLogcat(sdcardPath + "/vlc_logcat");
 
        defaultUEH.uncaughtException(thread, ex);
    } 
 
    private void writeLog(String log, String name) {
        CharSequence timestamp = DateFormat.format("yyyyMMdd_kkmmss", System.currentTimeMillis());
        String filename = name + "_" + timestamp + ".log";
 
        try { 
            FileOutputStream stream = new FileOutputStream(filename);
            OutputStreamWriter output = new OutputStreamWriter(stream);
            BufferedWriter bw = new BufferedWriter(output);
 
            bw.write(log);
            bw.newLine();
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:sleep, uncaughtException
        Thread.setDefaultUncaughtExceptionHandler(this);
    } 
 
    public void uncaughtException(Thread thread, Throwable throwable) {
        if (!handleException(throwable) && (mDefaultHandler != null)) {
            mDefaultHandler.uncaughtException(thread, throwable);
        } else { 
            try { 
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                Log.e(TAG, "发生线程异常", e);
            } 
 
            android.os.Process.killProcess(android.os.Process.myPid());
            System.exit(1);
        } 
    } 
 
    /** 
     * 提交异常信息到服务器 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:sleep, uncaughtException
	@Override 
	public void uncaughtException(Thread thread, Throwable ex) {
		// TODO Auto-generated method stub 
        if (!handleException(ex) && mDefaultHandler != null) {      
            //Èç¹ûÓû§Ã»Óд¦ÀíÔòÈÃϵͳĬÈϵÄÒì³£´¦ÀíÆ÷À´´¦Àí       
            mDefaultHandler.uncaughtException(thread, ex);      
        } else {       
            try {       
                Thread.sleep(3000);      
            } catch (InterruptedException e) {      
                Log.e(TAG, "error : ", e);      
            }       
            //Í˳ö³ÌÐò       
            android.os.Process.killProcess(android.os.Process.myPid());      
            System.exit(1);      
        }   
	} 
 
    /**    
     * ×Ô¶¨Òå´íÎó´¦Àí,ÊÕ¼¯´íÎóÐÅÏ¢ ·¢ËÍ´íÎ󱨸æµÈ²Ù×÷¾ùÔÚ´ËÍê³É.    
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:sleep, uncaughtException
	 */ 
	@Override 
	public void uncaughtException(Thread thread, Throwable ex) {
		if (!handleException(ex) && mDefaultHandler != null) {
			// Èç¹û×Ô¶¨ÒåµÄûÓд¦ÀíÔòÈÃϵͳĬÈϵÄÒì³£´¦ÀíÆ÷À´´¦Àí 
			mDefaultHandler.uncaughtException(thread, ex);
		} else { 
			try { 
				Thread.sleep(3000);		// Èç¹û´¦ÀíÁË£¬ÈóÌÐò¼ÌÐøÔËÐÐ3ÃëÔÙÍ˳ö£¬±£Ö¤Îļþ±£´æ²¢ÉÏ´«µ½·þÎñÆ÷
			} catch (InterruptedException e) {
				e.printStackTrace();
			} 
			 
			android.os.Process.killProcess(android.os.Process.myPid());
			System.exit(1);
		} 
	} 
 
	/** 
	 * ×Ô¶¨Òå´íÎó´¦Àí,ÊÕ¼¯´íÎóÐÅÏ¢ ·¢ËÍ´íÎ󱨸æµÈ²Ù×÷¾ùÔÚ´ËÍê³É. 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:sleep, uncaughtException
      
   @Override   
   public void uncaughtException(Thread thread, Throwable ex) {  
       if (!handleException(ex) && mDefaultHandler != null) {  
            
           mDefaultHandler.uncaughtException(thread, ex);  
       } else {   
           try {   
               Thread.sleep(3000);  
           } catch (InterruptedException e) {  
               Log.e(TAG, "error : ", e);  
           }   
            
           android.os.Process.killProcess(android.os.Process.myPid());  
           System.exit(1);  
       }   
   }   
  
    
   public static boolean isNetworkAvailable(Context context) {  
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:sleep, uncaughtException
	 */ 
	@Override 
	public void uncaughtException(Thread thread, Throwable ex) { 
		if (!handleException(ex) && mDefaultHandler != null) { 
			//如果用户没有处理则让系统默认的异常处理器来处理 
			mDefaultHandler.uncaughtException(thread, ex); 
		} else { 
			try { 
				Thread.sleep(3000); 
			} catch (InterruptedException e) { 
				Log.e(TAG, "error : ", e); 
			} 
			//退出程序 
			android.os.Process.killProcess(android.os.Process.myPid()); 
			System.exit(1); 
		} 
	} 
 
	/** 
	 * 自定义错误处理,收集错误信息 发送错误报告等操作均在此完成. 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 Thread.UncaughtExceptionHandler Questions & Answers:

See Code Examples for Java 8 Thread.UncaughtExceptionHandler Methods: