この記事(特に、この部分)の助けを借りて、解決策を見つけました。
まず、電話してない…
getLoaderManager().initLoader(MY_LOADER_ID, null, this);
...私の活動のonCreate
方法で。しかし、私が電話した場合にのみ正しい動作を達成しました...
getLoaderManager().restartLoader(MY_LOADER_ID, args, this);
...アクティビティが最初に実行されるときのみ。これは、新しいクエリの実行を停止する唯一の方法でした。
だから、ここに私の活動のメソッドからのスニペットがあります(私は私のとonCreate
を作成した直後に配置しました)...ViewPager
ScreenSlidePagerAdapter
getLoaderManager().initLoader(LOADER_ID_NORMAL, null, this);
boolean isFirstCreate = (savedInstanceState == null);
if (isFirstCreate) {
/*
* If this Activity was launched with a search intent, then perform the search
*/
parseIntent(getIntent()); //calls getLoaderManager().restartLoader()
}
else {
/*
* Hide the progress view
*/
searchProgressBar.setVisibility(View.INVISIBLE);
}
私にとっては適切に機能し、かなりクリーンなソリューションのように思えますが、他の提案は大歓迎です。
更新: 2015 年 8 月 2 日
私のコメントに基づいて、これが正しい方法だと思います:
if (getLoaderManager().getLoader(LOADER_ID_NORMAL) == null) {
/*
* Loader doesn't exist, so create and start it
*/
Bundle args = ...;
getLoaderManager().restartLoader(LOADER_ID_NORMAL, args, this); //calls onCreateLoader()
}
else {
/*
* Loader already exists so all we need to do is initialise it
*/
getLoaderManager().initLoader(LOADER_ID_NORMAL, null, this); //calls onCreateLoader()
}