我尝试展示活动(简介activity
)只有在activity
包含一个Button
(跳过)时才会显示点击跳过 button
MainActivity
将会显示,因为我使用SharedPreference
当我在Android 6.0或7.0上运行我的应用程序时工作正常,但当我运行它时Android 5.0.1(三星S4)跳过 button
可以正常工作但不能顺利地保持一段时间(3或4秒)。
Logcat :
java.lang.RuntimeException:执行不活动的停止 恢复: {com.android.settings / com.android.settings.applications.InstalledAppDetails}
简介活动:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.introactivity);
skip = (Button)findViewById(R.id.skip);
hide();
appPreferences = PreferenceManager.getDefaultSharedPreferences(this);
skip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences.Editor editor = appPreferences.edit();
editor.putBoolean("introSkipped", true);
editor.apply();
finish();
}
});
}
MainActivity:
SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(this);
if (!appPreferences.getBoolean("introSkipped", false)) {
Intent toIntro = new Intent(this, introactivity.class);
startActivity(toIntro);
}