如果出现TRY错误

时间:2015-09-13 11:46:38

标签: java android if-statement try-catch

我有一个问题,请解释一下,我是新来的。

因为

我发现了一次崩溃
 try{
    if(root.isChecked()==true){
       Runtime.getRuntime().exec("su");
    }
    } catch (IOException e){ }

我已经把这个,也APP崩溃了

try{
    if(root.isChecked()){
       Runtime.getRuntime().exec("su");
    }
    } catch (IOException e){ }

我也是这样测试的,没有运气也好:

if(root.isChecked()==true){
                    try{
                        Runtime.getRuntime().exec("su");
                    } catch (IOException e){ }
                }

但是当我使用我的测试时:

 try{
    if("a"=="a"){
       Runtime.getRuntime().exec("su");
    }
    } catch (IOException e){        }

一切都很好。有人可以解释一下。非常感谢你。

Log.d

09-13 14:26:20.939 20109 20109 E   Zygote pl.treno.ac                           MountEmulatedStorage()
09-13 14:26:20.939 20109 20109 E   Zygote pl.treno.ac                           v2
09-13 14:26:20.939 20109 20109 I   libpersona pl.treno.ac                       KNOX_SDCARD checking this for 10069
09-13 14:26:20.939 20109 20109 I   libpersona pl.treno.ac                       KNOX_SDCARD not a persona
09-13 14:26:20.959 20109 20109 I   SELinux pl.treno.ac                          Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_SM-G900F_5.0_0011
09-13 14:26:20.959 20109 20109 E   SELinux pl.treno.ac                          [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
09-13 14:26:20.959 20109 20109 I   art pl.treno.ac                              Late-enabling -Xcheck:jni
09-13 14:26:20.999 20109 20109 D   ResourcesManager pl.treno.ac                 creating new AssetManager and set to /data/app/pl.treno.ac-1/base.apk
09-13 14:26:21.069 20109 20109 D   Activity pl.treno.ac                         performCreate Call secproduct feature valuefalse
09-13 14:26:21.069 20109 20109 D   Activity pl.treno.ac                         performCreate Call debug elastic valuetrue
09-13 14:26:21.079 20109 20129 D   OpenGLRenderer pl.treno.ac                   Render dirty regions requested: true
09-13 14:26:21.109 20109 20129 I   Adreno-EGL pl.treno.ac                       <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build:  ()
09-13 14:26:21.109 20109 20129 I   Adreno-EGL pl.treno.ac                       OpenGL ES Shader Compiler Version: E031.25.01.03
09-13 14:26:21.109 20109 20129 I   Adreno-EGL pl.treno.ac                       Build Date: 03/03/15 Tue
09-13 14:26:21.109 20109 20129 I   Adreno-EGL pl.treno.ac                       Local Branch: LA.BF.1.1_RB1_20150108_025_1077123_1158499
09-13 14:26:21.109 20109 20129 I   Adreno-EGL pl.treno.ac                       Remote Branch:
09-13 14:26:21.109 20109 20129 I   Adreno-EGL pl.treno.ac                       Local Patches:
09-13 14:26:21.109 20109 20129 I   Adreno-EGL pl.treno.ac                       Reconstruct Branch:
09-13 14:26:21.109 20109 20129 I   OpenGLRenderer pl.treno.ac                   Initialized EGL, version 1.4
09-13 14:26:21.129 20109 20129 I   OpenGLRenderer pl.treno.ac                   HWUI protection enabled for context ,  &this =0xa2022088 ,&mEglDisplay = 1 , &mEglConfig = 8
09-13 14:26:21.139 20109 20129 D   OpenGLRenderer pl.treno.ac                   Enabling debug mode 0
09-13 14:26:21.179 20109 20109 I   Timeline pl.treno.ac                         Timeline: Activity_idle id: android.os.BinderProxy@2a9b6256 time:835825

Log.e

09-13 14:49:41.029 31968 31968 E   Zygote pl.treno.ac                           MountEmulatedStorage()
09-13 14:49:41.029 31968 31968 E   Zygote pl.treno.ac                           v2
09-13 14:49:41.029 31968 31968 I   libpersona pl.treno.ac                       KNOX_SDCARD checking this for 10069
09-13 14:49:41.029 31968 31968 I   libpersona pl.treno.ac                       KNOX_SDCARD not a persona
09-13 14:49:41.049 31968 31968 I   SELinux pl.treno.ac                          Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_SM-G900F_5.0_0011
09-13 14:49:41.049 31968 31968 E   SELinux pl.treno.ac                          [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
09-13 14:49:41.049 31968 31968 I   art pl.treno.ac                              Late-enabling -Xcheck:jni
09-13 14:49:41.109 31968 31968 D   ResourcesManager pl.treno.ac                 creating new AssetManager and set to /data/app/pl.treno.ac-1/base.apk
09-13 14:49:41.169 31968 31968 D   Activity pl.treno.ac                         performCreate Call secproduct feature valuefalse
09-13 14:49:41.169 31968 31968 D   Activity pl.treno.ac                         performCreate Call debug elastic valuetrue
09-13 14:49:41.179 31968 31988 D   OpenGLRenderer pl.treno.ac                   Render dirty regions requested: true
09-13 14:49:41.199 31968 31988 I   Adreno-EGL pl.treno.ac                       <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build:  ()
09-13 14:49:41.199 31968 31988 I   Adreno-EGL pl.treno.ac                       OpenGL ES Shader Compiler Version: E031.25.01.03
09-13 14:49:41.199 31968 31988 I   Adreno-EGL pl.treno.ac                       Build Date: 03/03/15 Tue
09-13 14:49:41.199 31968 31988 I   Adreno-EGL pl.treno.ac                       Local Branch: LA.BF.1.1_RB1_20150108_025_1077123_1158499
09-13 14:49:41.199 31968 31988 I   Adreno-EGL pl.treno.ac                       Remote Branch:
09-13 14:49:41.199 31968 31988 I   Adreno-EGL pl.treno.ac                       Local Patches:
09-13 14:49:41.199 31968 31988 I   Adreno-EGL pl.treno.ac                       Reconstruct Branch:
09-13 14:49:41.209 31968 31988 I   OpenGLRenderer pl.treno.ac                   Initialized EGL, version 1.4
09-13 14:49:41.219 31968 31988 I   OpenGLRenderer pl.treno.ac                   HWUI protection enabled for context ,  &this =0xa2022088 ,&mEglDisplay = 1 , &mEglConfig = 8
09-13 14:49:41.229 31968 31988 D   OpenGLRenderer pl.treno.ac                   Enabling debug mode 0
09-13 14:49:41.269 31968 31968 I   Timeline pl.treno.ac                         Timeline: Activity_idle id: android.os.BinderProxy@33306471 time:2235915
09-13 14:49:43.399 31968 31968 D   ViewRootImpl pl.treno.ac                     ViewPostImeInputStage ACTION_DOWN
09-13 14:49:43.439 31968 31968 I   Timeline pl.treno.ac                         Timeline: Activity_launch_request id:pl.treno.ac time:2238081
09-13 14:49:43.469 31968 31968 D   Activity pl.treno.ac                         performCreate Call secproduct feature valuefalse
09-13 14:49:43.469 31968 31968 D   Activity pl.treno.ac                         performCreate Call debug elastic valuetrue
09-13 14:49:43.529 31968 31968 I   Timeline pl.treno.ac                         Timeline: Activity_idle id: android.os.BinderProxy@326f3573 time:2238175
09-13 14:49:44.849 31968 31968 D   ViewRootImpl pl.treno.ac                     ViewPostImeInputStage ACTION_DOWN
09-13 14:49:44.919 31968 31968 I   Timeline pl.treno.ac                         Timeline: Activity_launch_request id:pl.treno.ac time:2239562
09-13 14:49:44.969 31968 31968 V   BitmapFactory pl.treno.ac                    DecodeImagePath(decodeResourceStream3) : res/drawable-xhdpi-v4/btn_check_on.png
09-13 14:49:44.969 31968 31968 V   BitmapFactory pl.treno.ac                    DecodeImagePath(decodeResourceStream3) : res/drawable-xhdpi-v4/btn_check_off.png
09-13 14:49:44.969 31968 31968 V   BitmapFactory pl.treno.ac                    DecodeImagePath(decodeResourceStream3) : res/drawable-xhdpi-v4/btn_check_on_pressed.png
09-13 14:49:44.969 31968 31968 V   BitmapFactory pl.treno.ac                    DecodeImagePath(decodeResourceStream3) : res/drawable-xhdpi-v4/btn_check_off_pressed.png
09-13 14:49:44.979 31968 31968 V   BitmapFactory pl.treno.ac                    DecodeImagePath(decodeResourceStream3) : res/drawable-xhdpi-v4/btn_check_on_selected.png
09-13 14:49:44.979 31968 31968 V   BitmapFactory pl.treno.ac                    DecodeImagePath(decodeResourceStream3) : res/drawable-xhdpi-v4/btn_check_off_selected.png
09-13 14:49:44.979 31968 31968 V   BitmapFactory pl.treno.ac                    DecodeImagePath(decodeResourceStream3) : res/drawable-xhdpi-v4/btn_check_on_disable.png
09-13 14:49:44.989 31968 31968 V   BitmapFactory pl.treno.ac                    DecodeImagePath(decodeResourceStream3) : res/drawable-xhdpi-v4/btn_check_off_disable.png
09-13 14:49:44.989 31968 31968 V   BitmapFactory pl.treno.ac                    DecodeImagePath(decodeResourceStream3) : res/drawable-hdpi-v4/btn_check_on_disable_focused.png
09-13 14:49:44.989 31968 31968 V   BitmapFactory pl.treno.ac                    DecodeImagePath(decodeResourceStream3) : res/drawable-xhdpi-v4/btn_check_off_disable_focused.png
09-13 14:49:44.999 31968 31968 D   Activity pl.treno.ac                         performCreate Call secproduct feature valuefalse
09-13 14:49:44.999 31968 31968 D   Activity pl.treno.ac                         performCreate Call debug elastic valuetrue
09-13 14:49:45.079 31968 31968 I   Timeline pl.treno.ac                         Timeline: Activity_idle id: android.os.BinderProxy@1e5ef392 time:2239728
09-13 14:50:04.199 32163 32163 E   Zygote pl.treno.ac                           MountEmulatedStorage()
09-13 14:50:04.209 32163 32163 E   Zygote pl.treno.ac                           v2
09-13 14:50:04.209 32163 32163 I   libpersona pl.treno.ac                       KNOX_SDCARD checking this for 10069
09-13 14:50:04.209 32163 32163 I   libpersona pl.treno.ac                       KNOX_SDCARD not a persona
09-13 14:50:04.209 32163 32163 I   SELinux pl.treno.ac                          Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_SM-G900F_5.0_0011
09-13 14:50:04.209 32163 32163 E   SELinux pl.treno.ac                          [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
09-13 14:50:04.209 32163 32163 I   art pl.treno.ac                              Late-enabling -Xcheck:jni
09-13 14:50:04.269 32163 32163 D   ResourcesManager pl.treno.ac                 creating new AssetManager and set to /data/app/pl.treno.ac-1/base.apk
09-13 14:50:04.329 32163 32163 D   Activity pl.treno.ac                         performCreate Call secproduct feature valuefalse
09-13 14:50:04.329 32163 32163 D   Activity pl.treno.ac                         performCreate Call debug elastic valuetrue
09-13 14:50:04.349 32163 32184 D   OpenGLRenderer pl.treno.ac                   Render dirty regions requested: true
09-13 14:50:04.389 32163 32184 I   Adreno-EGL pl.treno.ac                       <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build:  ()
09-13 14:50:04.389 32163 32184 I   Adreno-EGL pl.treno.ac                       OpenGL ES Shader Compiler Version: E031.25.01.03
09-13 14:50:04.389 32163 32184 I   Adreno-EGL pl.treno.ac                       Build Date: 03/03/15 Tue
09-13 14:50:04.389 32163 32184 I   Adreno-EGL pl.treno.ac                       Local Branch: LA.BF.1.1_RB1_20150108_025_1077123_1158499
09-13 14:50:04.389 32163 32184 I   Adreno-EGL pl.treno.ac                       Remote Branch:
09-13 14:50:04.389 32163 32184 I   Adreno-EGL pl.treno.ac                       Local Patches:
09-13 14:50:04.389 32163 32184 I   Adreno-EGL pl.treno.ac                       Reconstruct Branch:
09-13 14:50:04.389 32163 32184 I   OpenGLRenderer pl.treno.ac                   Initialized EGL, version 1.4
09-13 14:50:04.409 32163 32184 I   OpenGLRenderer pl.treno.ac                   HWUI protection enabled for context ,  &this =0xaec22088 ,&mEglDisplay = 1 , &mEglConfig = 8
09-13 14:50:04.419 32163 32184 D   OpenGLRenderer pl.treno.ac                   Enabling debug 

来自终端的LogCat

---- 13 wrz 2015 15:56:44 ----
09-13 15:56:13.113  6253  6253 I Timeline: Timeline: Activity_launch_request id:pl.treno.ac time:4341240
09-13 15:56:13.113  1052  2151 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=pl.treno.ac/.MainActivity} from uid 10027 on display 0
09-13 15:56:13.133  1052  3910 I ActivityManager: Start proc pl.treno.ac for activity pl.treno.ac/.MainActivity: pid=19082 uid=10069 gids={50069, 9997} abi=armeabi-v7a
09-13 15:56:13.143   250   250 I SurfaceFlinger: id=1021 createSurf (1080x1920),1 flag=404, Starting pl.treno.ac
09-13 15:56:13.303   250   250 I SurfaceFlinger: id=1022 createSurf (1080x1920),1 flag=404, pl.treno.ac/pl.treno.ac.MainActivity
09-13 15:56:13.393  1052  1096 I ActivityManager: Displayed pl.treno.ac/.MainActivity: +269ms
09-13 15:56:13.393  1052  1096 I Timeline: Timeline: Activity_windows_visible id: ActivityRecord{11fbaf43 u0 pl.treno.ac/.MainActivity t104} time:4341529
09-13 15:56:13.513   250 16968 I SurfaceFlinger: id=1021 Removed Starting pl.treno.ac (5/8)
09-13 15:56:13.513   250   358 I SurfaceFlinger: id=1021 Removed Starting pl.treno.ac (-2/8)
09-13 15:56:14.573 19082 19082 I Timeline: Timeline: Activity_launch_request id:pl.treno.ac time:4342703
09-13 15:56:14.583  1052  1079 I ActivityManager: START u0 {cmp=pl.treno.ac/.cleaner} from uid 10069 on display 0
09-13 15:56:14.633   250   250 I SurfaceFlinger: id=1023 createSurf (1x1),1 flag=404, pl.treno.ac/pl.treno.ac.cleaner
09-13 15:56:14.683  1052  1096 I ActivityManager: Displayed pl.treno.ac/.cleaner: +91ms
09-13 15:56:14.823   250  2432 I SurfaceFlinger: id=1022 Removed pl.treno.ac/pl.treno.ac.MainActivity (3/8)
09-13 15:56:14.823   250 16968 I SurfaceFlinger: id=1022 Removed pl.treno.ac/pl.treno.ac.MainActivity (-2/8)
09-13 15:56:14.883  1052  1096 I Timeline: Timeline: Activity_windows_visible id: ActivityRecord{189f0a6d u0 pl.treno.ac/.cleaner t104} time:4343016
09-13 15:56:17.643 19082 19082 I Timeline: Timeline: Activity_launch_request id:pl.treno.ac time:4345775
09-13 15:56:17.653  1052  3854 I ActivityManager: START u0 {cmp=pl.treno.ac/.cleaner_caches} from uid 10069 on display 0
09-13 15:56:17.733   250   250 I SurfaceFlinger: id=1024 createSurf (1x1),1 flag=404, pl.treno.ac/pl.treno.ac.cleaner_caches
09-13 15:56:17.803  1052  1096 I ActivityManager: Displayed pl.treno.ac/.cleaner_caches: +130ms
09-13 15:56:17.943   250  2242 I SurfaceFlinger: id=1023 Removed pl.treno.ac/pl.treno.ac.cleaner (3/8)
09-13 15:56:17.943   250   358 I SurfaceFlinger: id=1023 Removed pl.treno.ac/pl.treno.ac.cleaner (-2/8)
09-13 15:56:18.003  1052  1096 I Timeline: Timeline: Activity_windows_visible id: ActivityRecord{1ab711ab u0 pl.treno.ac/.cleaner_caches t104} time:4346133
09-13 15:56:19.143 19082 19082 E AndroidRuntime: Process: pl.treno.ac, PID: 19082
09-13 15:56:19.143 19082 19082 E AndroidRuntime:    at pl.treno.ac.cleaner_caches$100000002.onClick(cleaner_caches.java:54)
09-13 15:56:19.153  1052  3862 W ActivityManager:   Force finishing activity pl.treno.ac/.cleaner_caches
09-13 15:56:19.213   250   250 I SurfaceFlinger: id=1025 createSurf (49x49),1 flag=4, Application Error: pl.treno.ac
09-13 15:56:19.663  1052  1090 W ActivityManager: Activity pause timeout for ActivityRecord{1ab711ab u0 pl.treno.ac/.cleaner_caches t104 f}
09-13 15:56:20.923  1052  2400 I ActivityManager: Process pl.treno.ac (pid 19082)(adj 0) has died(74,291)
09-13 15:56:20.933  1052  2429 I WindowState: WIN DEATH: Window{12531d87 u0 pl.treno.ac/pl.treno.ac.cleaner_caches}
09-13 15:56:20.933  1052  3910 I WindowState: WIN DEATH: Window{2cd580d8 u0 pl.treno.ac/pl.treno.ac.MainActivity}
09-13 15:56:20.943  1052  3913 I WindowState: WIN DEATH: Window{33aee069 u0 pl.treno.ac/pl.treno.ac.cleaner}
09-13 15:56:20.963   250   250 I SurfaceFlinger: id=1026 createSurf (1x1),1 flag=404, Starting pl.treno.ac
09-13 15:56:20.973  1052  2400 I ActivityManager: Start proc pl.treno.ac for activity pl.treno.ac/.cleaner: pid=19181 uid=10069 gids={50069, 9997} abi=armeabi-v7a
09-13 15:56:21.013   250   351 I SurfaceFlinger: id=1025 Removed Application Error: pl.treno.ac (8/9)
09-13 15:56:21.013   250  2242 I SurfaceFlinger: id=1025 Removed Application Error: pl.treno.ac (-2/9)
09-13 15:56:21.043   250   351 I SurfaceFlinger: id=1024 Removed pl.treno.ac/pl.treno.ac.cleaner_caches (3/8)
09-13 15:56:21.043   250   358 I SurfaceFlinger: id=1024 Removed pl.treno.ac/pl.treno.ac.cleaner_caches (-2/8)
09-13 15:56:21.053   250  2432 I SurfaceFlinger: id=1024 Removed pl.treno.ac/pl.treno.ac.cleaner_caches (-2/8)
09-13 15:56:21.153   250   250 I SurfaceFlinger: id=1027 createSurf (1x1),1 flag=404, pl.treno.ac/pl.treno.ac.cleaner
09-13 15:56:21.263  1052  1096 I ActivityManager: Displayed pl.treno.ac/.cleaner: +313ms
09-13 15:56:21.263  1052  1096 I Timeline: Timeline: Activity_windows_visible id: ActivityRecord{189f0a6d u0 pl.treno.ac/.cleaner t104} time:4349395
09-13 15:56:21.393   250 16968 I SurfaceFlinger: id=1026 Removed Starting pl.treno.ac (5/8)
09-13 15:56:21.393   250   351 I SurfaceFlinger: id=1026 Removed Starting pl.treno.ac (-2/8)
09-13 15:56:22.003   250   351 I SurfaceFlinger: id=1027 Removed pl.treno.ac/pl.treno.ac.cleaner (6/8)
09-13 15:56:22.003   250  2242 I SurfaceFlinger: id=1027 Removed pl.treno.ac/pl.treno.ac.cleaner (-2/8)

此外,这个APP在请求root访问权限之前关闭,我知道它正在运行。因为“a”==“a”或没有,如果我收到根访问问题和一切正常工作。 使用终端日志I out,这是第42行的错误,如果

,则完全放置

0 个答案:

没有答案