2012-02-24 36 views
-5

我想要檢測應用程序崩潰的時間,並且需要保存它遇到的異常的日誌,因爲我們在eclipse中的logcat中。如何檢測應用程序何時崩潰並保存該日誌

+5

8.37不是[整數](http://en.wikipedia.org/wiki/Integer) – 2012-02-24 10:09:31

+1

8.37不是整數,8.37是浮點數。您需要使用NumberFormat或Double.parseDouble或Float.parseFloat解析它 – mcfinnigan 2012-02-24 10:10:54

回答

4

8.37不是整數,它需要一個float或double

0

8.37不是整數,它是一個浮點數。

你可以做這樣的事情

float f = Float.valueOf("8.37"); 

,或者如果你需要絕對的精確,你可以考慮使用

new BigDecimal("8.37"); 

0

你想要的東西,如:

string strSomePerc = "8.99%"; 

// For the real number. 
double dSomePerc = Convert.ToDouble(strSomePerc.Replace("%", String.Empty)); 

// For the integer. 
int nSomePerc = Convert.ToInt32(dSomePerc); 

注意,(如安德魯Logvinov曾表示)如果一個數字中有一個小數點,它不能是整數團伙的一部分。

相關問題