, пожалуйста, помогите кто-нибудь, я бы выйти из системы метода с использованием sweetalertdialog библиотеки, и этот выхода из системы под названием навигации ящикаНамерение иногда не работает без каких-либо ошибок
private void logout() {
SweetAlertDialog nDialog = new SweetAlertDialog(Master_Menu.this, SweetAlertDialog.CUSTOM_IMAGE_TYPE);
nDialog.setTitleText("Alert");
nDialog.setContentText("Are you sure you want to logout?");
nDialog.setConfirmText("Yes");
nDialog.setCancelText("No");
nDialog.setCustomImage(R.drawable.ic_launcher);
nDialog.setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
@Override
public void onClick(SweetAlertDialog nDialog) {
//Getting out sharedpreferences
SharedPreferences preferences = getSharedPreferences(Config.SHARED_PREF_NAME, Context.MODE_PRIVATE);
//Getting editor
SharedPreferences.Editor editor = preferences.edit();
String level = preferences.getString(Config.LEVEL_USER,"null");
//Puting the value false for loggedin
editor.putBoolean(Config.LOGGEDIN_SHARED_PREF, false);
//Stop the Service
if (level.equalsIgnoreCase("KRN")) {
stopService(new Intent(getApplicationContext(), getLocation.class));
Log.d("Service", "STOP");
}
//Putting blank value to email
editor.putString(Config.EMAIL_SHARED_PREF, "");
editor.putString(Config.ID_SHARED_PREF, "");
editor.putString(Config.TOKEN_SHARED_PREF, "");
editor.putString(Config.LEVEL_USER,"");
//Saving the sharedpreferences
editor.commit();
nDialog.dismiss();
//Starting login activity
Intent intent = new Intent(Master_Menu.this, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
});
nDialog.setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() {
@Override
public void onClick(SweetAlertDialog nDialog) {
nDialog.cancel();
}
});
nDialog.show();
}
иногда намерение loginActivity не работает, но Тереза нет проблемы с подтверждением нажмите слушателю, потому что все общие предпочтения были изменения после того, как я нажимаю подтвердить (то есть функция подтверждения работает)
это то, что я уже попробовать:
- Я думаю, что 2 намерения в 1 методе могут стать проблемой (stopervice и startactivity), но после того, как я прокомментирую остановку, проблема все еще происходит.
- Я не знаю различий в getapplicationcontext() и class.this в Intent, поэтому я просто пытаюсь перейти от class.this к getapplicationcontext(), потому что большинство моих намерений в этом проекте использует getapplicationcontext, но проблема все еще происходит.
дополнительная информация:
размер моего проекта (после чистого проекта) около 400MB
и это мой Lib
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/PhotoUtil.jar')
compile files('libs/GenAsync.1.2.jar')
compile files('libs/KGJsonConverter.jar')
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.volley:volley:1.0.0'
compile 'com.wdullaer:materialdatetimepicker:2.3.0'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.github.amigold.fundapter:library:1.0'
compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
compile 'com.android.support:support-v4:24.2.1'
compile 'me.spark:submitbutton:1.0.1'
compile 'com.jaredrummler:material-spinner:1.1.0'
compile 'com.android.support:cardview-v7:24.2.1'
compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
compile 'com.github.paolorotolo:appintro:4.0.0'
compile 'me.wangyuwei:ParticleView:1.0.4'
compile 'com.google.android.gms:play-services:8.4.0'
}
уже попробовал и попытался удалить nDialog.dismiss(); тоже, но проблема все еще там –