在2个不同的活动上使用TextInputEditText时的ANR

时间:2017-08-04 15:58:06

标签: android android-anr-dialog

我正在接受ANR。我有2个屏幕 - 注册和登录。当应用程序第一次加载时,它会打开注册活动,其中包含2个TextInputEditText(手机号码和密码)和一个登录按钮,单击该按钮会切换到登录活动。

  1. SignUp活动加载
  2. 我输入了手机号码和密码
  3. 现在,我点击“登录”按钮,启动“登录活动”,再次显示“移动号码和密码”字段
  4. 我在登录活动中键入手机号码和密码,现在我点击注册按钮,使用Intent Flag FLAG_ACTIVITY_REORDER_TO_FRONT
  5. 将我带回旧的注册活动
  6. 现在,当我尝试在注册活动中编辑手机号码时,我无法输入任何数字 - >似乎应用程序已冻结
  7. 请注意:在进行测试时,我没有在任何这些活动中向服务器提交请求。我只是输入然后切换到另一个选项。 我还有一个Firebase服务。

    代码:

    public class SignInActivity extends AppCompatActivity {
        private final String TAG = SignInActivity.class.getSimpleName();
        TextInputEditText mMobileNumberView, mPasswordView;
        TextInputLayout mPasswordTextInputLayout, mMobileNumberTextInputLayout;
    
        Button mLoginButtonView;
        Button mRegisterButtonView;
        Button mForgotPasswordButtonView;
        TextView mCredAlternateOptionLabel;
    
    
    
    
        @Override
        public void onCreate(@Nullable Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.signin);
    
            mMobileNumberView = (TextInputEditText) findViewById(R.id.signin_text_mobile_number);
            mPasswordView = (TextInputEditText) findViewById(R.id.signin_text_password);
            mLoginButtonView = (Button) findViewById(R.id.signin_button_submit);
            mRegisterButtonView = (Button) findViewById(R.id.signin_button_cred_alternate_option);
            mForgotPasswordButtonView = (Button) findViewById(R.id.signin_button_forgot_password);
            mCredAlternateOptionLabel = (TextView) findViewById(R.id.signin_text_cred_alternate_option);
    
            mPasswordTextInputLayout = (TextInputLayout) findViewById(R.id.signin_text_input_layout_password);
            mMobileNumberTextInputLayout = (TextInputLayout) findViewById(R.id.signin_text_input_layout_mobile_number);
    
    
            mPasswordTextInputLayout.setHint(getResources().getString(R.string.signin_password_hint));
            mLoginButtonView.setText(R.string.signin_login_btn);
            mCredAlternateOptionLabel.setText(R.string.signin_text_cred_alternate_option);
    
            mRegisterButtonView.setText(R.string.signin_register_btn);
            mForgotPasswordButtonView.setText(R.string.signin_forgot_password);
    
            mRegisterButtonView.setOnClickListener(new View.OnClickListener(){
                @Override
                public void onClick(View v) {
                    Intent signUpIntent = new Intent(SignInActivity.this, SignUpActivity.class);
                    signUpIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                    startActivity(signUpIntent);
                }
            });
    
            mForgotPasswordButtonView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent forgotPasswordIntent = new Intent(SignInActivity.this, ForgotPassword.class);
                    forgotPasswordIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                    startActivity(forgotPasswordIntent);
                }
            });
    
    
            mLoginButtonView.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    // Do something in response to button click
                }
            });
      }
    
      }      
    
    
    public class SignUpActivity extends AppCompatActivity {
        private static final String TAG = SignUpActivity.class.getSimpleName();
        TextInputEditText mMobileNumberView, mCreatePasswordView;
        TextInputLayout mPasswordTextInputLayout, mMobileNumberTextInputLayout;
    
    
        Button mLoginButtonView;
        Button mContinueButtonView;
        TextView mCredAlternateOptionLabel;
    
    
        @Override
        protected void onRestart() {
            super.onRestart();
            Log.i(TAG, "onRestart called ===>");
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            Log.i(TAG, "onResume called ====>");
    
        }
    
        @Override
        protected void onStart() {
            super.onStart();
            Log.i(TAG, "onStart called ===>");
    
        }
    
        @Override
        protected void onCreate(@Nullable Bundle savedInstanceState)  {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.signup);
    
            mPasswordTextInputLayout = (TextInputLayout) findViewById(R.id.signup_text_input_layout_password);
            mCreatePasswordView = (TextInputEditText) findViewById(R.id.signup_text_password);
            mContinueButtonView = (Button) findViewById(R.id.signup_button_submit);
            mLoginButtonView = (Button) findViewById(R.id.signup_button_cred_alternate_option);
            mCredAlternateOptionLabel = (TextView) findViewById(R.id.signup_text_cred_alternate_option);
    
            mMobileNumberTextInputLayout = (TextInputLayout) findViewById(R.id.signup_text_input_layout_mobile_number);
    
            mPasswordTextInputLayout.setHint(getResources().getString(R.string.signup_create_password_hint));
            mContinueButtonView.setText(R.string.signup_continue_btn);
            mCredAlternateOptionLabel.setText(R.string.signup_text_cred_alternate_option);
            mLoginButtonView.setText(R.string.signup_login_btn);
    
            mMobileNumberView = (TextInputEditText) findViewById(R.id.signup_text_mobile_number);
    
    
    
            mLoginButtonView.setOnClickListener(new View.OnClickListener(){
                @Override
                public void onClick(View v) {
                  /*  ActivityManager mngr = (ActivityManager) getSystemService( ACTIVITY_SERVICE );
    
                    List<ActivityManager.RunningTaskInfo> taskList = mngr.getRunningTasks(10);
    
                   for(int i = 0; i < taskList.size(); i++) {
                        Log.i(TAG, "activity " + i + " " + taskList.get(i).topActivity.getClassName());
                    }*/
    
                    Intent signInIntent = new Intent(SignUpActivity.this, SignInActivity.class);
                    signInIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                    startActivity(signInIntent);
                }
            });
    
            mContinueButtonView.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    // Do something in response to button click
                }
            });
    
          }
      }              
    
    :09:38.726 6022-6421/system_process V/WindowManager: Adding window Window{3eeb90bf u0 PopupWindow:3ef77b8} at 4 of 12 (after Window{1ba0a7b8 u0 com.example.jitenshah.abc/com.example.jitenshah.abc.SignUpActivity})
    08-04 21:09:39.246 6022-6421/system_process V/WindowManager: Adding window Window{1493cf51 u0 PopupWindow:3188e0f6} at 6 of 13 (after Window{3eeb90bf u0 PopupWindow:3ef77b8 EXITING})
    08-04 21:09:41.978 6022-6068/system_process I/InputDispatcher: Dropped event because the current application is not responding and the user has started interacting with a different application.
    08-04 21:09:41.979 6022-6068/system_process I/InputDispatcher: Dropped event because the current application is not responding and the user has started interacting with a different application.
    08-04 21:09:41.979 6022-6068/system_process I/InputDispatcher: Dropped event because the current application is not responding and the user has started interacting with a different application.
    08-04 21:09:41.980 6022-6068/system_process I/InputDispatcher: Dropped event because the current application is not responding and the user has started interacting with a different application.
    08-04 21:09:41.981 6022-6068/system_process I/InputDispatcher: Dropped event because the current application is not responding and the user has started interacting with a different application.
    08-04 21:09:41.982 6022-6068/system_process I/InputDispatcher: Dropped event because the current application is not responding and the user has started interacting with a different application.
    08-04 21:09:42.197 6022-6432/system_process V/WindowManager: Adding window Window{274d8b7 u0 PopupWindow:3188e0f6} at 6 of 13 (after Window{1493cf51 u0 PopupWindow:3188e0f6 EXITING})
    08-04 21:09:42.670 7328-7348/com.example.jitenshah.abc V/FA: Inactivity, disconnecting from the service
    08-04 21:09:47.699 6022-6068/system_process I/InputDispatcher: Application is not responding: AppWindowToken{3536c51c token=Token{3b401e8f ActivityRecord{27f9ee u0 com.google.android.googlequicksearchbox/com.google.android.launcher.GEL t53}}}.  It has been 5004.6ms since event, 5003.9ms since wait started.  Reason: Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.
    08-04 21:09:47.701 6022-6068/system_process I/WindowManager: Input event dispatching timed out sending to application AppWindowToken{3536c51c token=Token{3b401e8f ActivityRecord{27f9ee u0 com.google.android.googlequicksearchbox/com.google.android.launcher.GEL t53}}}.  Reason: Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.
    08-04 21:09:47.713 6022-6041/system_process I/Process: Sending signal. PID: 6345 SIG: 3
    08-04 21:09:47.714 6345-6353/com.google.android.googlequicksearchbox I/art: Thread[3,tid=6353,WaitingInMainSignalCatcherLoop,Thread*=0xf4026000,peer=0x12c070a0,"Signal Catcher"]: reacting to signal 3
    08-04 21:09:47.752 6345-6353/com.google.android.googlequicksearchbox I/art: Wrote stack traces to '/data/anr/traces.txt'
    08-04 21:09:47.752 6022-6041/system_process I/Process: Sending signal. PID: 6022 SIG: 3
    08-04 21:09:47.753 6022-6029/system_process I/art: Thread[3,tid=6029,WaitingInMainSignalCatcherLoop,Thread*=0x7f70f6c95800,peer=0x12c020a0,"Signal Catcher"]: reacting to signal 3
    08-04 21:09:52.712 6022-6068/system_process I/InputDispatcher: Application is not responding: AppWindowToken{3536c51c token=Token{3b401e8f ActivityRecord{27f9ee u0 com.google.android.googlequicksearchbox/com.google.android.launcher.GEL t53}}}.  It has been 9897.6ms since event, 5005.6ms since wait started.  Reason: Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.
    08-04 21:09:58.513 6022-6029/system_process W/libbacktrace: void ThreadEntry::Wait(int): pthread_cond_timedwait failed: Connection timed out
    08-04 21:09:58.736 6022-6041/system_process I/Process: Sending signal. PID: 6323 SIG: 3
    08-04 21:09:58.737 6323-6330/com.android.phone I/art: Thread[3,tid=6330,WaitingInMainSignalCatcherLoop,Thread*=0x7f70f6c95800,peer=0x12c000a0,"Signal Catcher"]: reacting to signal 3
    08-04 21:09:58.739 6022-6041/system_process I/Process: Sending signal. PID: 6129 SIG: 3
    08-04 21:09:58.739 6129-6144/com.android.systemui I/art: Thread[3,tid=6144,WaitingInMainSignalCatcherLoop,Thread*=0x7f70f6c95800,peer=0x12c000a0,"Signal Catcher"]: reacting to signal 3
    08-04 21:09:58.741 6022-6068/system_process I/WindowManager: Input event dispatching timed out sending to application AppWindowToken{3536c51c token=Token{3b401e8f ActivityRecord{27f9ee u0 com.google.android.googlequicksearchbox/com.google.android.launcher.GEL t53}}}.  Reason: Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.
    08-04 21:09:58.743 6022-6068/system_process I/InputDispatcher: Dropped event because it is stale.
    08-04 21:09:58.746 6022-6029/system_process I/art: Wrote stack traces to '/data/anr/traces.txt'
    08-04 21:09:58.823 6129-6144/com.android.systemui I/art: Wrote stack traces to '/data/anr/traces.txt'
    08-04 21:09:58.894 6323-6330/com.android.phone I/art: Wrote stack traces to '/data/anr/traces.txt'
    08-04 21:09:59.745 6022-6041/system_process I/art: Explicit concurrent mark sweep GC freed 26452(1152KB) AllocSpace objects, 4(202KB) LOS objects, 28% free, 10MB/14MB, paused 1.795ms total 33.233ms
    08-04 21:10:00.271 6022-6041/system_process E/ActivityManager: ANR in com.google.android.googlequicksearchbox (com.google.android.googlequicksearchbox/com.google.android.launcher.GEL)
                                                                   PID: 6345
                                                                   Reason: Input dispatching timed out (Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.)
                                                                   Load: 0.55 / 1.07 / 0.72
                                                                   CPU usage from 0ms to 12558ms later:
                                                                     101% 6022/system_server: 0.6% user + 100% kernel / faults: 6230 minor
                                                                     3% 1129/adbd: 0.1% user + 2.8% kernel / faults: 2930 minor
                                                                     0.5% 6323/com.android.phone: 0.2% user + 0.2% kernel / faults: 2689 minor
                                                                     0.2% 6129/com.android.systemui: 0.1% user + 0.1% kernel / faults: 1937 minor
                                                                     0% 1132/debuggerd64: 0% user + 0% kernel / faults: 821 minor
                                                                     0.1% 6345/com.google.android.googlequicksearchbox: 0% user + 0% kernel / faults: 912 minor
                                                                     0% 6/kworker/u4:0: 0% user + 0% kernel
                                                                     0% 1666/sdcard: 0% user + 0% kernel
                                                                     0% 6288/com.google.android.gms.persistent: 0% user + 0% kernel / faults: 2 minor
                                                                     0% 6666/com.google.android.gms: 0% user + 0% kernel
                                                                     0% 7328/com.example.jitenshah.abc: 0% user + 0% kernel / faults: 2 minor
                                                                     0% 7397/logcat: 0% user + 0% kernel / faults: 33 minor
                                                                   54% TOTAL: 1.6% user + 52% kernel + 0% iowait
                                                                   CPU usage from 12038ms to 12546ms later:
                                                                     100% 6022/system_server: 1.9% user + 98% kernel
                                                                       98% 6081/Thread-48: 0% user + 98% kernel
                                                                     3.3% 1129/adbd: 0% user + 3.3% kernel / faults: 127 minor
                                                                       1.6% 1138/adbd: 0% user + 1.6% kernel
                                                                       1.6% 1139/adbd: 0% user + 1.6% kernel
                                                                     1.7% 6323/com.android.phone: 1.7% user + 0% kernel
                                                                   54% TOTAL: 0.9% user + 53% kernel
    08-04 21:10:00.272 6022-6041/system_process I/ActivityManager: Killing 6345:com.google.android.googlequicksearchbox/u0a13 (adj 0): bg anr
    08-04 21:10:00.277 6022-6068/system_process W/InputDispatcher: channel '2eea918 com.google.android.googlequicksearchbox/com.google.android.launcher.GEL (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
    08-04 21:10:00.277 6022-6068/system_process E/InputDispatcher: channel '2eea918 com.google.android.googlequicksearchbox/com.google.android.launcher.GEL (server)' ~ Channel is unrecoverably broken and will be disposed!
    08-04 21:10:00.279 6022-6393/system_process I/WindowState: WIN DEATH: Window{2eea918 u0 com.google.android.googlequicksearchbox/com.google.android.launcher.GEL}
    08-04 21:10:00.279 6022-6393/system_process W/InputDispatcher: Attempted to unregister already unregistered input channel '2eea918 com.google.android.googlequicksearchbox/com.google.android.launcher.GEL (server)'
    
                                                                   [ 08-04 21:10:00.296  6022: 6405 D/         ]
                                                                   HostConnection::get() New Host Connection established 0x7f70ed4e3200, tid 6405
    08-04 21:10:00.376 1124-1124/? E/EGL_emulation: tid 1124: eglCreateSyncKHR(1299): error 0x3004 (EGL_BAD_ATTRIBUTE)
    08-04 21:10:00.516 6022-6046/system_process W/art: Long monitor contention event with owner method=android.graphics.Bitmap com.android.server.wm.WindowManagerService.screenshotApplications(android.os.IBinder, int, int, int, boolean) from WindowManagerService.java:6129 waiters=0 for 224ms
    08-04 21:10:00.522 7328-7348/com.example.jitenshah.abc V/FA: Recording user engagement, ms: 22938
    08-04 21:10:00.522 7328-7348/com.example.jitenshah.abc V/FA: Using measurement service
    08-04 21:10:00.522 7328-7348/com.example.jitenshah.abc V/FA: Connecting to remote service
    08-04 21:10:00.525 7328-7348/com.example.jitenshah.abc V/FA: Activity paused, time: 789582
    08-04 21:10:00.528 7328-7348/com.example.jitenshah.abc D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=22938, _sc=SignUpActivity, _si=1181000433361205426}]
    08-04 21:10:00.537 6022-6022/system_process W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied() from ActivityManagerService.java:1228 waiters=3 for 200ms
    08-04 21:10:00.559 7328-7348/com.example.jitenshah.abc V/FA: Using measurement service
    08-04 21:10:00.559 7328-7348/com.example.jitenshah.abc V/FA: Connection attempt already in progress
    08-04 21:10:00.560 6022-6036/system_process I/ActivityManager: Start proc 7978:com.google.android.googlequicksearchbox/u0a13 for activity com.google.android.googlequicksearchbox/com.google.android.launcher.GEL
    08-04 21:10:00.564 7328-7348/com.example.jitenshah.abc D/FA: Connected to remote service
    08-04 21:10:00.564 7328-7348/com.example.jitenshah.abc V/FA: Processing queued up service tasks: 2
    08-04 21:10:00.594 7978-7986/? I/art: Debugger is no longer active
    08-04 21:10:00.626 6666-7365/com.google.android.gms V/FA-SVC: Logging event: origin=auto,name=_e,params=Bundle[mParcelledData.dataSize=136]
    08-04 21:10:00.637 6666-7365/com.google.android.gms V/FA-SVC: Saving event, name, data size: _e, 70
    08-04 21:10:00.638 6666-7365/com.google.android.gms V/FA-SVC: Event recorded: Event{appId='com.example.jitenshah.abc', name='_e', params=Bundle[{_o=auto, _et=22938, _sc=SignUpActivity, _si=1181000433361205426}]}
    08-04 21:10:00.644 6666-7365/com.google.android.gms V/FA-SVC: Upload scheduled in approximately ms: 994441
    08-04 21:10:00.651 6666-7365/com.google.android.gms V/FA-SVC: Background event processing time, ms: 25
    08-04 21:10:00.765 6022-6041/system_process I/Process: Sending signal. PID: 6022 SIG: 3
    08-04 21:10:00.766 6022-6029/system_process I/art: Thread[3,tid=6029,WaitingInMainSignalCatcherLoop,Thread*=0x7f70f6c95800,peer=0x12c020a0,"Signal Catcher"]: reacting to signal 3
    08-04 21:10:00.782 7978-7978/? W/ResourceType: Attempt to retrieve bag 0x7f0e0039 which is invalid or in a cycle.
    08-04 21:10:05.621 7328-7348/com.example.jitenshah.abc V/FA: Inactivity, disconnecting from the service
    08-04 21:10:23.105 5743-5743/? I/Zygote: Process 6022 exited due to signal (33)
    08-04 21:10:23.105 5743-5743/? E/Zygote: Exit zygote because system server (1740406991) has terminated
    08-04 21:10:23.155 1142-1142/? I/art: Explicit concurrent mark sweep GC freed 711(30KB) AllocSpace objects, 0(0B) LOS objects, 91% free, 92KB/1116KB, paused 517us total 46.270ms
    08-04 21:10:23.175 1142-1142/? I/art: Explicit concurrent mark sweep GC freed 5(160B) AllocSpace objects, 0(0B) LOS objects, 91% free, 92KB/1116KB, paused 705us total 18.624ms
    08-04 21:10:23.202 1142-1142/? I/art: Explicit concurrent mark sweep GC freed 5(160B) AllocSpace objects, 0(0B) LOS objects, 91% free, 92KB/1116KB, paused 1.078ms total 19.039ms
    08-04 21:10:23.206 1122-1122/? I/ServiceManager: service 'iphonesubinfo' died
    08-04 21:10:23.206 1122-1122/? I/ServiceManager: service 'simphonebook' died
    

    启用严格政策后

    On further investigation using StrictPolicy found this : 
    5:27.581 2908-2908/com.example.jitenshah.abc W/art: Verification of void com.example.jitenshah.abc.SignInActivity.onCreate(android.os.Bundle) took 134.880ms
    08-04 21:35:27.589 2908-2908/com.example.jitenshah.abc V/FA: onActivityCreated
    08-04 21:35:27.676 2908-2918/com.example.jitenshah.abc E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
                                                                               java.lang.Throwable: Explicit termination method 'close' not called
                                                                                   at dalvik.system.CloseGuard.open(CloseGuard.java:184)
                                                                                   at android.database.CursorWindow.<init>(CursorWindow.java:111)
                                                                                   at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)
                                                                                   at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:139)
                                                                                   at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:133)
                                                                                   at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:197)
                                                                                   at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:237)
                                                                                   at com.google.android.gms.internal.zzatg.zza(Unknown Source)
                                                                                   at com.google.android.gms.internal.zzatg.zza(Unknown Source)
                                                                                   at com.google.android.gms.internal.zzatw.zzc(Unknown Source)
                                                                                   at com.google.android.gms.internal.zzatu.zzb(Unknown Source)
                                                                                   at com.google.android.gms.internal.zzatu.zza(Unknown Source)
                                                                                   at com.google.android.gms.internal.zzatu$4.run(Unknown Source)
                                                                                   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
                                                                                   at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                                   at com.google.android.gms.internal.zzato$zzd.run(Unknown Source)
    

0 个答案:

没有答案