Ushmajit Sikdar
Ushmajit Sikdar

Reputation: 11

Starting an acitvity form where the user left

Is it possible to start an activity from where the user left before closing the app in android using shared preferences or any other technique?

Upvotes: 0

Views: 36

Answers (1)

Amaresh Jana
Amaresh Jana

Reputation: 742

I have never tried but there is a chance of doing that but the first activity should be splashActivity....Check the shared preference value of the activity and then send to the corresponding activity....

public void checkActivityCount() {
        AppPreference mAppreference = new AppPreference(SplashActivity.this);

        int activityCount = mAppPreference.getActivityCount();

        switch(activityCount) {

        case 1 :
            Intent iNext = new Intent(SplashActivity.this, DashboardActivity.class);
            startActivity(iNext);
            break;

        case 2 :
            Intent iNext = new Intent(SplashActivity.this, DashboardActivity.class);
            startActivity(iNext);
            break;
        }
    }

Create a unique int value for diff activity and store them in the shared preference.....

Hope this will help you Happeeee...programming.....

Upvotes: 1

Related Questions