从后台返回时,Android应用无法正常运行

时间:2018-02-21 23:34:10

标签: android android-recyclerview

问题:

将应用程序置于后台并回归它会让行为变得奇怪。奇怪,因为几乎所有我的应用程序功能都无法正常工作。例如,单击应用程序的多个工具栏操作按钮时,没有人响应。他们什么都不做。更不用说应用程序感觉缓慢而缓慢。

情景:

如果关闭和回到应用程序之间的时间间隔相对较短,那么将应用程序置于后台并回到它有时可以正常工作,假设不到30分钟。虽然我仍然不知道时间是什么原因,或者当我的应用程序在后台时,我是否同时使用其他应用程序。

你觉得我的Nexus 5X在这里有问题吗?我也尝试过另一部手机(三星Galaxy A5),问题仍然存在。或者我的应用程序有问题吗?任何帮助将不胜感激。

OnResume():(此处没有附加侦听器)

    @Override
protected void onResume() {
    super.onResume();

    // We call to set them on the outside of the if statement because another startActivity on the settings page is called when we change theme there
    // if old theme setting isn't equal to the new one: change theme cuz an update to this setting has happened
    if (mDarkTheme != mSettingsValue.getDarkTheme()) {
        Intent intent = new Intent(this, MainActivity.class);
        // Clears the old SettingsActivity
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
    }

    // we don't wanna call this each time onresume is called, oly when back from settings page
    if (backFromSettingsPage) {
        if (mSettingsValue == null) {
            mSettingsValue = new Settings(this);
        }

        // here we don't check if it's different but every other settings value we check if (old != new)
        mToolbarColorChange = mSettingsValue.toChangeToolbarColor();

        // Change region: this refreshes for new data
        // if old region id isn't equal to new region id
        if (mRegionId != mSettingsValue.getRegionId()) {
            mRegionId = mSettingsValue.getRegionId();
            mUpcomingGamesFragment.refresh();
        }

        boolean releasePasWeekBool = false;
        boolean releasesDuplicatesBool = false;
        // Hide/show pas week of releases
        boolean newReleasesPastWeek = mSettingsValue.toShowPastWeek();
        releasePasWeekBool = true;
        // if old != new (if value has changed)
        if (mReleasesPastWeek != newReleasesPastWeek) {
            releasePasWeekBool = true;
            // mUpcomingGamesFragment.notifyForUpdatedData();
        }

        // Hide/show Limited editions of games
        boolean removeDuplicates = mSettingsValue.getRemoveDuplicates();
        // if old != new (if value has changed) [Value has changed]
        if (mRemoveDuplicates != removeDuplicates) {
            releasesDuplicatesBool= true;
            // mUpcomingGamesFragment.notifyForUpdatedData();
        }

        if (releasePasWeekBool || releasesDuplicatesBool) {
            mUpcomingGamesFragment.refreshUpcomingList();
        }

    }
    backFromSettingsPage = false;
}

0 个答案:

没有答案