0

i'm trying to show an activity (introduction activity) appears only once this activity contains one Button (Skip), when user click in skip button MainActivity will showing so for that i use SharedPreference when i run my app on android 6.0 or 7.0 works fine but when i run it on android 5.0.1 ( Samsung S4 ) the skip button works but not in a smooth way he keep stuck for a while(3 or 4 seconds ) .

Logcat :

java.lang.RuntimeException: Performing stop of activity that is not resumed: {com.android.settings/com.android.settings.applications.InstalledAppDetails}

Intro Activity :

 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);
        }
S.Queroane
  • 77
  • 2
  • 12
  • 1
    Your problem is witth exception or with time taking on skiping – Abdul Waheed Nov 06 '17 at 12:45
  • @AbdulWaheed with time taking to skipping – S.Queroane Nov 06 '17 at 12:47
  • 1
    This will not solve your problem but it is always a good idea to explicitly name the activity you want to finish with IntroActivity.this.finish(). – botzek13 Nov 06 '17 at 13:06
  • 1
    Where are you calling the startActivity(IntroActivityIntent) in? In onResume() of MainActivity? Maybe you have a loop here! Please extend your code snippets. – botzek13 Nov 06 '17 at 13:17
  • @botzek13 for the time being i don't use `onResume()` for calling `startActivity(toIntro);` – S.Queroane Nov 06 '17 at 13:20
  • @botzek13 i tried to call `SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(this); if (!appPreferences.getBoolean("introSkipped", false)) { Intent toIntro = new Intent(this, useheadphone.class); startActivity(toIntro); }` in `onResume()` and i have the same problem – S.Queroane Nov 06 '17 at 13:24
  • 1
    Please check with getDefaultSharedPreferencesName if the SharedPrefs are one and the same for IntroActivity.context and MainActivity.context. But I think the problem is the moment of starting your IntroActivity. See https://stackoverflow.com/a/23246159/4871489 and try the Handler-version of delayed starting of the IntroActivity. – botzek13 Nov 06 '17 at 13:44
  • @botzek13 thanks i checked it and i have the same name – S.Queroane Nov 06 '17 at 13:47

0 Answers0