我使用共享偏好设置,以便在第一次登录后,下次用户启动应用时,不应打开SignInActivity。在使用共享偏好设置 " onClickbuttonListener" 之前效果很好并打开了SignInActivity,但后来我删除了Sharedpreferences代码,然后点击按钮不会再次打开 SignInActivity 。请帮帮我。 在 onClickListener()中,如果我添加其他活动而不是SignInActivity,则可以正常工作,
主要活动
public void onClickButtonListener(){
signUpBtn = (Button)findViewById(R.id.button);
signUpBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), SignInActivity.class);
startActivity(intent);
}
});
}
logcat的
05-11 02:55:13.131 2612-2612/? E/Zygote: v2
05-11 02:55:13.131 2612-2612/? I/libpersona: KNOX_SDCARD checking this for 10221
05-11 02:55:13.131 2612-2612/? I/libpersona: KNOX_SDCARD not a persona
05-11 02:55:13.131 2612-2612/? I/SELinux: Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_SM-J700H_5.1.1_0026
05-11 02:55:13.131 2612-2612/? E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
05-11 02:55:13.131 2612-2612/? I/art: Late-enabling -Xcheck:jni
05-11 02:55:13.141 2612-2612/? D/TimaKeyStoreProvider: in addTimaSignatureService
05-11 02:55:13.141 2612-2612/? D/TimaKeyStoreProvider: TimaSignature is unavailable
05-11 02:55:13.141 2612-2612/? D/ActivityThread: Added TimaKesytore provider
05-11 02:55:13.151 2612-2622/? I/art: Debugger is no longer active
05-11 02:55:13.161 2612-2612/? W/ResourcesManager: getTopLevelResources: com.sourcey.materialloginexample for user 0
05-11 02:55:13.161 2612-2612/? I/InjectionManager: Inside getClassLibPath + mLibMap{0=, 1=}
05-11 02:55:13.171 2612-2612/? I/InjectionManager: Inside getClassLibPath caller
05-11 02:55:13.171 2612-2612/? D/InjectionManager: InjectionManager
05-11 02:55:13.171 2612-2612/? D/InjectionManager: fillFeatureStoreMap com.sourcey.materialloginexample
05-11 02:55:13.171 2612-2612/? I/InjectionManager: Constructor com.sourcey.materialloginexample, Feature store :{}
05-11 02:55:13.171 2612-2612/? I/InjectionManager: featureStore :{}
05-11 02:55:13.181 2612-2612/? W/ResourcesManager: getTopLevelResources: com.sourcey.materialloginexample for user 0
05-11 02:55:13.181 2612-2612/? W/ResourcesManager: getTopLevelResources: com.sourcey.materialloginexample for user 0
05-11 02:55:13.181 2612-2612/? D/DisplayManager: DisplayManager()
05-11 02:55:13.221 2612-2612/? D/PhoneWindow: *FMB* installDecor mIsFloating : false
05-11 02:55:13.221 2612-2612/? D/PhoneWindow: *FMB* installDecor flags : -2139029248
05-11 02:55:13.431 2612-2612/? D/Activity: performCreate Call Injection manager
05-11 02:55:13.431 2612-2612/? I/InjectionManager: dispatchOnViewCreated > Target : com.sourcey.materiallogindemo.MainActivity isFragment :false
05-11 02:55:13.441 2612-2658/? D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
05-11 02:55:13.451 2612-2612/? D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
05-11 02:55:13.451 2612-2612/? D/PhoneWindow: *FMB* isFloatingMenuEnabled return false
05-11 02:55:13.511 2612-2658/? D/libEGL: loaded /vendor/lib/egl/libGLES_mali.so
05-11 02:55:13.541 2612-2658/? I/OpenGLRenderer: Initialized EGL, version 1.4
05-11 02:55:13.551 2612-2658/? D/OpenGLRenderer: Enabling debug mode 0
05-11 02:55:13.561 2612-2658/? D/mali_winsys: new_window_surface returns 0x3000, [720x1280]-format:1
05-11 02:55:13.751 2612-2612/? I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@3feab8e6 time:22282717
05-11 02:55:16.511 2612-2612/com.sourcey.materialloginexample D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
05-11 02:55:16.581 2612-2612/com.sourcey.materialloginexample I/Timeline: Timeline: Activity_launch_request id:com.sourcey.materialloginexample time:22285543
05-11 02:55:16.601 2612-2612/com.sourcey.materialloginexample W/ResourcesManager: getTopLevelResources: com.sourcey.materialloginexample for user 0
05-11 02:55:16.601 2612-2612/com.sourcey.materialloginexample D/PhoneWindow: *FMB* installDecor mIsFloating : false
05-11 02:55:16.601 2612-2612/com.sourcey.materialloginexample D/PhoneWindow: *FMB* installDecor flags : -2139029248
05-11 02:55:16.651 2612-2612/com.sourcey.materialloginexample D/Activity: performCreate Call Injection manager
05-11 02:55:16.681 2612-2612/com.sourcey.materialloginexample I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@3feab8e6 time:22285643
答案 0 :(得分:0)
您必须在活动中创建方法goSignInActivity
。
public void goSignInActivity(View v) {
Intent intent = new Intent(getApplicationContext(),YOUR_SIGNIN_ACTIVITY.class);
startActivity(intent);
}
现在,如果您点击buttonstrt
或致电goSignInActivity()
代码即可。您必须在menifest.xml文件中注册LoginActivity。