java.lang.StringIndexOutOfBoundsException - 只是在应用程序的特定点...为什么?

时间:2014-05-17 20:55:57

标签: java android debugging exception view

我在这一行得到了一个java.lang.StringIndexOutOfBoundsException:

timer.start();

在这种方法中:

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        switch(parent.getId()){
            case R.id.list_subject:
                quizWorld.setSubject(quizWorld.getSubjects().get((int) id));

                ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(this, R.layout.list_item, R.id.listItem, quizWorld.getCategories());
                list_category.setAdapter(adapter2);
                state = GameState.Category;
                viewSlider.next();
                break;
            case R.id.list_category:
                quizWorld.setCategory(quizWorld.getCategories().get((int) id));

                quizWorld.swapQuestion();
                state = GameState.Running;
                timer.start();
                viewSlider.next();
                break;
        }
    }

当我打电话给&#34; timmer.start();&#34;在其他任何方法的其他地方它的工作。即使我使用调试器,我也没有错误。仅在此特定方法中且仅在正常模式下不在调试器模式下。

对象计时器的类的代码:

public class TimerView extends TextView{

    private Handler handler = new Handler();
    private long startTime;
    private long elapsedTime;
    private final int REFRESH_RATE = 100;
    private String hours,minutes,seconds,milliseconds;
    private long secs,mins,hrs;
    private boolean stopped = false;

    public TimerView(Context context){
        super(context);
    }

    public TimerView (Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public TimerView(Context context, AttributeSet attrs, int defStyle){
        super(context, attrs, defStyle);
    }

    public void start(){
        if(stopped){
            startTime = System.currentTimeMillis() - elapsedTime; 
        }
        else{
            startTime = System.currentTimeMillis();
        }
        handler.removeCallbacks(startTimer);
        handler.postDelayed(startTimer, 0);
    }

    public void stop(){
        handler.removeCallbacks(startTimer);
        stopped = true;
    }

    private Runnable startTimer = new Runnable() {
           public void run() {
               elapsedTime = System.currentTimeMillis() - startTime;
               updateTimer(elapsedTime);
               handler.postDelayed(this,REFRESH_RATE);
           }
        };

    private void updateTimer (float time){
        secs = (long)(time/1000);
        mins = (long)((time/1000)/60);
        hrs = (long)(((time/1000)/60)/60);

        /* Convert the seconds to String 
         * and format to ensure it has
         * a leading zero when required
         */
        secs = secs % 60;
        seconds=String.valueOf(secs);
    if(secs == 0){
        seconds = "00";
    }
    if(secs <10 && secs > 0){
        seconds = "0"+seconds;
    }

        /* Convert the minutes to String and format the String */

    mins = mins % 60;
        minutes=String.valueOf(mins);
    if(mins == 0){
        minutes = "00";
    }
    if(mins <10 && mins > 0){
        minutes = "0"+minutes;
    }

    /* Convert the hours to String and format the String */

    hours=String.valueOf(hrs);
    if(hrs == 0){
        hours = "00";
    }
    if(hrs <10 && hrs > 0){
        hours = "0"+hours;
    }

    /* Although we are not using milliseconds on the timer in this example
     * I included the code in the event that you wanted to include it on your own
     */
    milliseconds = String.valueOf((long)time);
    if(milliseconds.length()==2){
        milliseconds = "0"+milliseconds;
    }
    if(milliseconds.length()<=1){
        milliseconds = "00";
    }
        milliseconds = milliseconds.substring(milliseconds.length()-3, milliseconds.length()-2);

        /* Setting the timer text to the elapsed time */
        this.setText(minutes + ":" + seconds + "." + milliseconds);
        //activity.((TextView)findViewById(R.id.timerMs)).setText("." + milliseconds);
    }
}

ViewSlider:

public class ViewSlider extends ViewFlipper{

    private ViewFlipListener viewFlipListener;

    public ViewSlider(Context context) {
        super(context);
    }

    public ViewSlider(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void setViewFlipListener(ViewFlipListener viewFlipListener){
        this.viewFlipListener = viewFlipListener;
    }

    public void next(){
        viewFlipListener.onViewFlip(true);
        super.showNext();
    }

    public void previous(){
        viewFlipListener.onViewFlip(false);
        super.showPrevious();
    }
}

logcat的:

05-17 16:54:56.390: E/CameraController(2380): setCamreaParameter with mode: 1 service_type: 100
05-17 16:54:56.390: E/CameraController(2380): Preview Size Is Not Supported (maybe auto-mode). Auto-Select
05-17 16:54:56.390: E/CameraController(2380): Front Camera Support 320, 320 preview
05-17 16:54:56.395: E/ISecCameraHardware(1971): FocusMode=infinity, PrevFocusMode=infinity
05-17 16:54:56.395: E/ISecCameraHardware(1971): preview window is NULL!
05-17 16:54:56.395: E/CameraController(2380): StartPreview()
05-17 16:54:56.540: E/CameraController(2380): StartPreview() X
05-17 16:54:56.540: E/CameraController(2380): handleMessage signal: 1
05-17 16:54:56.540: E/CameraController(2380): handleMessage(1) before let go!{ what=1 when=-274ms arg1=4 }
05-17 16:54:56.540: E/CameraController(2380): handleMessage(1) after let go!{ what=1 when=-274ms arg1=4 }
05-17 16:54:56.540: E/CameraController(2380): handleMessage, lock.unlock before
05-17 16:54:56.540: E/CameraController(2380): waitHere, 272ms
05-17 16:54:56.540: E/CameraController(2380): Wait for 1 DONE!
05-17 16:54:56.540: E/CameraController(2380): sendMessageAndWait, lock.unlock before
05-17 16:54:56.540: E/CameraController(2380): sendMessageAndWait, lock.unlock after
05-17 16:54:56.540: E/CameraController(2380): openCamera E
05-17 16:54:56.665: E/CameraController(2380): handleMessage(1) after unlock{ what=1 when=-274ms arg1=4 }
05-17 16:54:56.665: E/SmartFaceManager(2380): Listener does not implements SmartFaceInfoListener2
05-17 16:54:56.825: E/SmartScreen_JNI(2380): processImage start : prev time [ 286146625 ]
05-17 16:54:56.825: E/SmartFaceService(2380): Orientation: 0
05-17 16:54:56.825: E/SmartFaceService(2380): Calling onPreviewFrame: Thread[Stay/Rotation Worker,5,main]/57610331
05-17 16:54:56.880: E/SmartFaceService(2380): Orientation: 0
05-17 16:54:56.880: E/SmartFaceService(2380): Calling onPreviewFrame: Thread[Stay/Rotation Worker,5,main]/57610386
05-17 16:54:56.940: E/SmartFaceService(2380): Orientation: 0
05-17 16:54:56.945: E/SmartFaceService(2380): Calling onPreviewFrame: Thread[Stay/Rotation Worker,5,main]/57610450
05-17 16:54:57.000: E/SmartFaceService(2380): Orientation: 0
05-17 16:54:57.000: E/SmartFaceService(2380): Calling onPreviewFrame: Thread[Stay/Rotation Worker,5,main]/57610508
05-17 16:54:57.060: E/SmartFaceService(2380): Orientation: 0
05-17 16:54:57.060: E/SmartFaceService(2380): Calling onPreviewFrame: Thread[Stay/Rotation Worker,5,main]/57610567
05-17 16:54:57.120: E/SmartFaceService(2380): Orientation: 0
05-17 16:54:57.120: E/SmartFaceService(2380): Calling onPreviewFrame: Thread[Stay/Rotation Worker,5,main]/57610625
05-17 16:54:57.150: E/SmartScreen_JNI(2380): processImage end : function time [ 326847 ] [-1] 
05-17 16:54:57.150: E/Stay/Rotation Worker(2380): processSmartStay[327ms], ret: -1 needToStay: 0 mFrameCount: 0 mFixed: false
05-17 16:54:57.155: E/SmartFaceManager(2380): checkForSmartStay onInfo: 100: 0
05-17 16:54:57.155: E/SmartScreen_JNI(2380): processImage start : prev time [ 329032 ]
05-17 16:54:57.190: E/SmartFaceService(2380): Orientation: 0
05-17 16:54:57.190: E/SmartFaceService(2380): Calling onPreviewFrame: Thread[Stay/Rotation Worker,5,main]/57610696
05-17 16:54:57.240: E/SmartFaceService(2380): Orientation: 0
05-17 16:54:57.240: E/SmartFaceService(2380): Calling onPreviewFrame: Thread[Stay/Rotation Worker,5,main]/57610749
05-17 16:54:57.305: E/SmartFaceService(2380): Orientation: 0
05-17 16:54:57.305: E/SmartFaceService(2380): Calling onPreviewFrame: Thread[Stay/Rotation Worker,5,main]/57610814
05-17 16:54:57.415: E/SmartScreen_JNI(2380): processImage end : function time [ 261694 ] [-1] 
05-17 16:54:57.490: E/SmartScreen_JNI(2380): processImage start : prev time [ 335746 ]
05-17 16:54:57.490: E/SmartFaceManager(2380): checkForSmartStay onInfo: 100: 0
05-17 16:54:57.490: E/Stay/Rotation Worker(2380): processSmartStay[262ms], ret: -1 needToStay: 0 mFrameCount: 1 mFixed: false
05-17 16:54:57.490: E/SmartFaceService(2380): Orientation: 0
05-17 16:54:57.490: E/SmartFaceService(2380): Calling onPreviewFrame: Thread[Stay/Rotation Worker,5,main]/57610997
05-17 16:54:57.490: E/SmartFaceService(2380): unregister:57610998
05-17 16:54:57.490: E/SmartFaceService(2380): unregister
05-17 16:54:57.490: E/SmartFaceService(2380): unregister client found. pid 2380 servicetype: 100 AppName: system
05-17 16:54:57.490: E/SmartFaceService(2380): send LastServiecTypeFromClient to scroll pause worker: 0
05-17 16:54:57.490: E/SmartFaceService(2380): mLightIntensityEnough: true mLux: 0.0
05-17 16:54:57.490: E/SmartFaceService(2380): Service Type to Worker: 0
05-17 16:54:57.490: E/SmartFaceService(2380): Last Active clients:1 Current Active clients: 0
05-17 16:54:57.490: E/SmartFaceService(2380): Last Smart Pause clients: 0 Current Smart Pause clients: 0
05-17 16:54:57.490: E/SmartFaceService(2380): No active clients. close camera
05-17 16:54:57.495: E/CameraController(2380): closeCamera S
05-17 16:54:57.495: E/CameraController(2380): sendMessageAndWait, lock.lock before
05-17 16:54:57.495: E/CameraController(2380): sendMessageAndWait, lock.lock after
05-17 16:54:57.495: E/CameraController(2380): handleMessage(0) before lock{ what=0 when=0 }
05-17 16:54:57.495: E/CameraController(2380): Wait for 0
05-17 16:54:57.495: E/CameraController(2380): waitHere, condition var. will be used. related lock release and re-acquired after await done.
05-17 16:54:57.495: E/CameraController(2380): handleMessage, lock.lock after
05-17 16:54:57.495: E/CameraController(2380): handleMessage(0) after lock{ what=0 when=-2ms }
05-17 16:54:57.580: E/SmartFaceService(2380): Clear worker messages
05-17 16:54:57.585: E/CameraController(2380): handleMessage signal: 0
05-17 16:54:57.585: E/CameraController(2380): handleMessage(0) before let go!{ what=0 when=-93ms }
05-17 16:54:57.590: E/SmartFaceManager(2380): checkForSmartStay X: false
05-17 16:54:57.590: E/CameraController(2380): handleMessage(0) after let go!{ what=0 when=-97ms }
05-17 16:54:57.590: E/CameraController(2380): handleMessage, lock.unlock before
05-17 16:54:57.590: E/CameraController(2380): handleMessage(0) after unlock{ what=0 when=-97ms }
05-17 16:54:57.590: E/CameraController(2380): waitHere, 95ms
05-17 16:54:57.590: E/CameraController(2380): Wait for 0 DONE!
05-17 16:54:57.590: E/CameraController(2380): sendMessageAndWait, lock.unlock before
05-17 16:54:57.590: E/CameraController(2380): sendMessageAndWait, lock.unlock after
05-17 16:54:57.590: E/CameraController(2380): closeCamera E
05-17 16:54:57.590: E/SmartFaceService(2380): mWakeLock.release() in FD
05-17 16:54:57.590: E/PowerManagerService(2380): [smart stay] handleSmartStay : canceled (T:1344ms)
05-17 16:54:57.730: E/SmartScreen_JNI(2380): processImage end : function time [ 239832 ] [-1] 
05-17 16:54:57.730: E/Stay/Rotation Worker(2380): processSmartStay[240ms], ret: -1 needToStay: 0 mFrameCount: 2 mFixed: false
05-17 16:54:57.755: E/NfcService(2942): callback == null
05-17 16:54:57.760: E/SELinux(25713): Function: selinux_android_load_priority [0], There is no sepolicy file 
05-17 16:54:57.760: E/SELinux(25713):  
05-17 16:54:57.770: E/SELinux(25713): Function: selinux_android_load_priority , loading version is VE=SEPF_GT-I9305_4.3_0021
05-17 16:54:57.770: E/SELinux(25713):  
05-17 16:54:57.770: E/SELinux(25713):  
05-17 16:54:57.770: E/SELinux(25713): selinux_android_seapp_context_reload: seapp_contexts file is loaded from /data/security/spota/seapp_contexts
05-17 16:54:57.800: E/MotionRecognitionService(2380):   mReceiver.onReceive : ACTION_USER_PRESENT  :: UNLOCK SCREEN
05-17 16:54:57.955: E/EnterpriseContainerManager(2380): ContainerPolicy Service is not yet ready!!!
05-17 16:54:58.095: E/InputDispatcher(2380): channel ~ Channel is unrecoverably broken and will be disposed!
05-17 16:54:58.095: E/InputDispatcher(2380): channel ~ Channel is unrecoverably broken and will be disposed!
05-17 16:55:00.320: E/com.amazon.mp3/com.amazon.identity.auth.device.framework.MAPApplicationInformationQueryer(15827): Notified by action android.intent.action.PACKAGE_REMOVED to invalidate app cache
05-17 16:55:00.375: E/com.amazon.mp3/com.amazon.identity.auth.device.framework.MAPApplicationInformationQueryer(15827): Notified by action android.intent.action.PACKAGE_ADDED to invalidate app cache
05-17 16:55:00.375: E/Watchdog(2380): !@Sync 1917
05-17 16:55:00.505: E/com.amazon.mp3/com.amazon.identity.auth.device.framework.MAPApplicationInformationQueryer(15827): Notified by action android.intent.action.PACKAGE_REPLACED to invalidate app cache
05-17 16:55:01.275: E/com.amazon.mp3/com.amazon.identity.auth.device.framework.MAPApplicationInformationQueryer(15827): Notified by action android.intent.action.PACKAGE_REMOVED to invalidate app cache
05-17 16:55:01.590: E/EnterpriseContainerManager(14658): ContainerPolicy Service is not yet ready!!!
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658): Failed at EnterpriseContainerManager API getEnterpriseContainerManager 
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658): java.lang.NoSuchFieldException: Container with Id 1 does not exists
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658):     at com.sec.enterprise.knox.EnterpriseContainerManager.<init>(EnterpriseContainerManager.java:706)
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658):     at com.sec.enterprise.knox.EnterpriseKnoxManager.getEnterpriseContainerManager(EnterpriseKnoxManager.java:243)
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658):     at com.sec.knox.containeragent.core.ContainerServiceAdapter.getInstance(ContainerServiceAdapter.java:55)
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658):     at com.sec.knox.containeragent.upgrade.knox.UpgradeInstallReceiver.onReceive(UpgradeInstallReceiver.java:36)
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2525)
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658):     at android.app.ActivityThread.access$1600(ActivityThread.java:159)
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1392)
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658):     at android.os.Looper.loop(Looper.java:137)
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658):     at android.app.ActivityThread.main(ActivityThread.java:5419)
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658):     at java.lang.reflect.Method.invokeNative(Native Method)
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658):     at java.lang.reflect.Method.invoke(Method.java:525)
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
05-17 16:55:01.595: E/EnterpriseKnoxManager(14658):     at dalvik.system.NativeStart.main(Native Method)
05-17 16:55:01.595: E/ECS_EnterpriseContainerService(2380): getStatus(). This will be same as getContainerActivation status
05-17 16:55:01.595: E/ECS_EnterpriseContainerCacheData(2380): There is no entry in cache for containerId1
05-17 16:55:01.595: E/ECS_ContainerStorageProvider(2380): updatebuilderobj
05-17 16:55:01.600: E/ECS_ContainerDatabase(2380): Container DB is null cannot fetch the status
05-17 16:55:01.600: E/ECS_EnterpriseContainerService(2380): getMountStatus() permission get it
05-17 16:55:01.605: E/ECS_EnterpriseContainerCacheData(2380): There is no entry in cache for containerId1
05-17 16:55:01.605: E/ECS_ContainerStorageProvider(2380): updatebuilderobj
05-17 16:55:01.605: E/ECS_ContainerDatabase(2380): Container DB is null cannot fetch the status
05-17 16:55:02.110: E/Parcel(14684): Reading a NULL string not supported here.
05-17 16:55:02.385: E/com.amazon.mp3/com.amazon.identity.auth.device.framework.MAPApplicationInformationQueryer(15827): Notified by action android.intent.action.PACKAGE_ADDED to invalidate app cache
05-17 16:55:02.410: E/SELinux(25775): Function: selinux_android_load_priority [0], There is no sepolicy file 
05-17 16:55:02.410: E/SELinux(25775):  
05-17 16:55:02.410: E/SELinux(25775): Function: selinux_android_load_priority , loading version is VE=SEPF_GT-I9305_4.3_0021
05-17 16:55:02.410: E/SELinux(25775):  
05-17 16:55:02.410: E/SELinux(25775):  
05-17 16:55:02.410: E/SELinux(25775): selinux_android_seapp_context_reload: seapp_contexts file is loaded from /data/security/spota/seapp_contexts
05-17 16:55:04.230: E/(25775): Device driver API match
05-17 16:55:04.230: E/(25775): Device driver API version: 23
05-17 16:55:04.230: E/(25775): User space API version: 23 
05-17 16:55:04.230: E/(25775): mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Wed Oct 30 09:36:10 KST 2013 
05-17 16:55:04.295: E/EnterpriseContainerManager(2380): ContainerPolicy Service is not yet ready!!!
05-17 16:55:04.410: E/StatusBar.NetworkController(2765): updateVD2DataNetType:2
05-17 16:55:08.190: E/DatabaseUtils(2380): Writing exception to parcel
05-17 16:55:08.190: E/DatabaseUtils(2380): java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
05-17 16:55:08.190: E/DatabaseUtils(2380):  at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:13101)
05-17 16:55:08.190: E/DatabaseUtils(2380):  at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2038)
05-17 16:55:08.190: E/DatabaseUtils(2380):  at com.android.providers.settings.SettingsProvider.callFromPackage(SettingsProvider.java:607)
05-17 16:55:08.190: E/DatabaseUtils(2380):  at android.content.ContentProvider$Transport.call(ContentProvider.java:279)
05-17 16:55:08.190: E/DatabaseUtils(2380):  at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:273)
05-17 16:55:08.190: E/DatabaseUtils(2380):  at android.os.Binder.execTransact(Binder.java:388)
05-17 16:55:08.190: E/DatabaseUtils(2380):  at dalvik.system.NativeStart.run(Native Method)
05-17 16:55:08.785: E/EnterpriseContainerManager(2380): ContainerPolicy Service is not yet ready!!!
05-17 16:55:10.015: E/DatabaseUtils(2380): Writing exception to parcel
05-17 16:55:10.015: E/DatabaseUtils(2380): java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
05-17 16:55:10.015: E/DatabaseUtils(2380):  at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:13101)
05-17 16:55:10.015: E/DatabaseUtils(2380):  at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2038)
05-17 16:55:10.015: E/DatabaseUtils(2380):  at com.android.providers.settings.SettingsProvider.callFromPackage(SettingsProvider.java:607)
05-17 16:55:10.015: E/DatabaseUtils(2380):  at android.content.ContentProvider$Transport.call(ContentProvider.java:279)
05-17 16:55:10.015: E/DatabaseUtils(2380):  at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:273)
05-17 16:55:10.015: E/DatabaseUtils(2380):  at android.os.Binder.execTransact(Binder.java:388)
05-17 16:55:10.015: E/DatabaseUtils(2380):  at dalvik.system.NativeStart.run(Native Method)
05-17 16:55:11.025: E/DatabaseUtils(2380): Writing exception to parcel
05-17 16:55:11.025: E/DatabaseUtils(2380): java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
05-17 16:55:11.025: E/DatabaseUtils(2380):  at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:13101)
05-17 16:55:11.025: E/DatabaseUtils(2380):  at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2038)
05-17 16:55:11.025: E/DatabaseUtils(2380):  at com.android.providers.settings.SettingsProvider.callFromPackage(SettingsProvider.java:607)
05-17 16:55:11.025: E/DatabaseUtils(2380):  at android.content.ContentProvider$Transport.call(ContentProvider.java:279)
05-17 16:55:11.025: E/DatabaseUtils(2380):  at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:273)
05-17 16:55:11.025: E/DatabaseUtils(2380):  at android.os.Binder.execTransact(Binder.java:388)
05-17 16:55:11.025: E/DatabaseUtils(2380):  at dalvik.system.NativeStart.run(Native Method)
05-17 16:55:11.030: E/AndroidRuntime(25775): FATAL EXCEPTION: main
05-17 16:55:11.030: E/AndroidRuntime(25775): java.lang.StringIndexOutOfBoundsException: length=2; regionStart=-1; regionLength=1
05-17 16:55:11.030: E/AndroidRuntime(25775):    at java.lang.String.startEndAndLength(String.java:583)
05-17 16:55:11.030: E/AndroidRuntime(25775):    at java.lang.String.substring(String.java:1464)
05-17 16:55:11.030: E/AndroidRuntime(25775):    at de.lipsksoft.apps.anwendung.t6student2.TimerView.updateTimer(TimerView.java:107)
05-17 16:55:11.030: E/AndroidRuntime(25775):    at de.lipsksoft.apps.anwendung.t6student2.TimerView.access$3(TimerView.java:58)
05-17 16:55:11.030: E/AndroidRuntime(25775):    at de.lipsksoft.apps.anwendung.t6student2.TimerView$1.run(TimerView.java:53)
05-17 16:55:11.030: E/AndroidRuntime(25775):    at android.os.Handler.handleCallback(Handler.java:730)
05-17 16:55:11.030: E/AndroidRuntime(25775):    at android.os.Handler.dispatchMessage(Handler.java:92)
05-17 16:55:11.030: E/AndroidRuntime(25775):    at android.os.Looper.loop(Looper.java:137)
05-17 16:55:11.030: E/AndroidRuntime(25775):    at android.app.ActivityThread.main(ActivityThread.java:5419)
05-17 16:55:11.030: E/AndroidRuntime(25775):    at java.lang.reflect.Method.invokeNative(Native Method)
05-17 16:55:11.030: E/AndroidRuntime(25775):    at java.lang.reflect.Method.invoke(Method.java:525)
05-17 16:55:11.030: E/AndroidRuntime(25775):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
05-17 16:55:11.030: E/AndroidRuntime(25775):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
05-17 16:55:11.030: E/AndroidRuntime(25775):    at dalvik.system.NativeStart.main(Native Method)
05-17 16:55:11.595: E/android.os.Debug(2380): !@Dumpstate > sdumpstate -k -t -z -d -o /data/log/dumpstate_app_error
05-17 16:55:13.050: E/ViewRootImpl(2380): sendUserActionEvent() mView == null
05-17 16:55:13.090: E/InputDispatcher(2380): channel ~ Channel is unrecoverably broken and will be disposed!
05-17 16:55:13.110: E/SELinux(25831): Function: selinux_android_load_priority [0], There is no sepolicy file 
05-17 16:55:13.110: E/SELinux(25831):  
05-17 16:55:13.115: E/SELinux(25831): Function: selinux_android_load_priority , loading version is VE=SEPF_GT-I9305_4.3_0021
05-17 16:55:13.115: E/SELinux(25831):  
05-17 16:55:13.115: E/SELinux(25831):  
05-17 16:55:13.115: E/SELinux(25831): selinux_android_seapp_context_reload: seapp_contexts file is loaded from /data/security/spota/seapp_contexts
05-17 16:55:14.480: E/(25831): Device driver API match
05-17 16:55:14.480: E/(25831): Device driver API version: 23
05-17 16:55:14.480: E/(25831): User space API version: 23 
05-17 16:55:14.480: E/(25831): mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Wed Oct 30 09:36:10 KST 2013 
05-17 16:55:14.550: E/EnterpriseContainerManager(2380): ContainerPolicy Service is not yet ready!!!
05-17 16:55:15.300: E/SELinux(25862): Function: selinux_android_load_priority [0], There is no sepolicy file 
05-17 16:55:15.300: E/SELinux(25862):  
05-17 16:55:15.300: E/SELinux(25862): Function: selinux_android_load_priority , loading version is VE=SEPF_GT-I9305_4.3_0021
05-17 16:55:15.300: E/SELinux(25862):  
05-17 16:55:15.300: E/SELinux(25862):  
05-17 16:55:15.300: E/SELinux(25862): selinux_android_seapp_context_reload: seapp_contexts file is loaded from /data/security/spota/seapp_contexts
05-17 16:55:16.515: E/SELinux(25878): Function: selinux_android_load_priority [0], There is no sepolicy file 
05-17 16:55:16.515: E/SELinux(25878):  
05-17 16:55:16.530: E/SELinux(25878): Function: selinux_android_load_priority , loading version is VE=SEPF_GT-I9305_4.3_0021
05-17 16:55:16.530: E/SELinux(25878):  
05-17 16:55:16.530: E/SELinux(25878):  
05-17 16:55:16.530: E/SELinux(25878): selinux_android_seapp_context_reload: seapp_contexts file is loaded from /data/security/spota/seapp_contexts
05-17 16:55:16.710: E/SELinux(25901): Function: selinux_android_load_priority [0], There is no sepolicy file 
05-17 16:55:16.710: E/SELinux(25901):  
05-17 16:55:16.710: E/SELinux(25901): Function: selinux_android_load_priority , loading version is VE=SEPF_GT-I9305_4.3_0021
05-17 16:55:16.710: E/SELinux(25901):  
05-17 16:55:16.710: E/SELinux(25901):  
05-17 16:55:16.710: E/SELinux(25901): selinux_android_seapp_context_reload: seapp_contexts file is loaded from /data/security/spota/seapp_contexts

你有什么想法吗?

1 个答案:

答案 0 :(得分:1)

这可能不是完整的怀疑答案,但对于评论来说太长了,所以请从downvoting中选择。我认为错误在这里:

   milliseconds = milliseconds.substring(milliseconds.length()-3, milliseconds.length()-2);

如果你得到毫秒&lt; = 1,那么你将毫秒设置为&#34; 00&#34;。然后,不可能获得milliseconds.length-3的子字符串。所以一个解决方案,不是很干净,而是一个解决方案,就是这样做:

   if(milliseconds.length()>=3){


   milliseconds = milliseconds.substring(milliseconds.length()-3,   milliseconds.length()-2);

   }

只需设置if语句,所以你可以肯定,只有当字符串足够长才能获得这样的子字符串时才会调用它。