Note that there are some explanatory texts on larger screens.

plurals
  1. POAsyncTask in Fragment v4 not call onPostExecute on 2.2 but call on 2.3 to latest version of android
    primarykey
    data
    text
    <p>I have a problem with Fragment that it doesn't call onPostExecute on 2.2 but call on 2.3 to latest version of android.</p> <p>I tried to find the solution a few days but not found.</p> <p>My code of this fragment</p> <pre><code>public class MovieFragment extends SherlockFragment implements IHomeScreen, OnItemClickListener, IActivity { private FrameLayout loading = null; private ListView listView = null; private ListMovieAdapter listMovieAdapter = null; private boolean isFavorite = false; private boolean isSearch = false; private String strSearch = null; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); return inflater.inflate(R.layout.fragment_movie, container, false); } @Override public void onViewCreated(View view, Bundle savedInstanceState) { init(view); initObjectListener(); super.onViewCreated(view, savedInstanceState); } @Override public void onActivityCreated(Bundle savedInstanceState) { if (strSearch == null) { loadingDataFromLocal(); } else { loadingDataFromServer(strSearch); } super.onActivityCreated(savedInstanceState); } @Override public void init() { } @Override public void initFormValidation() { } @Override public void init(View v) { listView = (ListView) v.findViewById(R.id.listView); loading = (FrameLayout) v.findViewById(R.id.loading); loading.setVisibility(View.GONE); } @Override public void initObjectListener() { listView.setOnItemClickListener(this); } @Override public void loadingDataFromServer() { } public void loadingDataFromServer(String strSearch) { if (Utils.isOnline(getActivity())) { new LoadingDataFromServer().execute(strSearch); } } public void refreshList(List&lt;EntryVO&gt; entryVOs) { listMovieAdapter = new ListMovieAdapter(getSherlockActivity(), entryVOs, isFavorite); listView.setAdapter(listMovieAdapter); } @Override public void loadingDataFromLocal() { Utils.log(new Exception(), "[isFavorite]" + isFavorite); if (isFavorite) { refreshList(DataSourceDAO.getFavorite(getSherlockActivity())); return; } } @Override public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position, long arg3) { if (Utils.isOnline(getActivity())) { String youtubeID = listMovieAdapter.getItem(position).getYoutubeID(); Utils.log(new Exception(), "[position]" + position + "[youtubeID]" + youtubeID); new YoutubePlayer(getSherlockActivity(), youtubeID); } else { Toast.makeText(getActivity(), R.string.no_internet_connection, Toast.LENGTH_LONG).show(); } } class LoadingDataFromServer extends AsyncTask&lt;String, Void, List&lt;EntryVO&gt;&gt; { @Override protected void onPreExecute() { super.onPreExecute(); Utils.log(new Exception(), "[onPreExecute]"); if (isSearch) { Utils.showProgressDialog(R.string.searching, getSherlockActivity()); } } @Override protected void onPostExecute(List&lt;EntryVO&gt; result) { super.onPostExecute(result); Utils.log(new Exception(), "[onPostExecute]"); Utils.dismissProgressDialog(); refreshList(result); } @Override protected List&lt;EntryVO&gt; doInBackground(String... params) { Utils.log(new Exception(), "[doInBackground]"); String search = params[0]; List&lt;EntryVO&gt; entryVOs = new SearchYoutubeAPI().searchYoutube(search); Utils.log(new Exception(), "[entryVOs]" + entryVOs.size()); return entryVOs; } } </code></pre> <p>}</p> <p>But if I tested it copy </p> <pre><code>class LoadingDataFromServer extends AsyncTask&lt;String, Void, List&lt;EntryVO&gt;&gt; { @Override protected void onPreExecute() { super.onPreExecute(); Utils.log(new Exception(), "[onPreExecute]"); if (isSearch) { Utils.showProgressDialog(R.string.searching, getSherlockActivity()); } } @Override protected void onPostExecute(List&lt;EntryVO&gt; result) { super.onPostExecute(result); Utils.log(new Exception(), "[onPostExecute]"); Utils.dismissProgressDialog(); refreshList(result); } @Override protected List&lt;EntryVO&gt; doInBackground(String... params) { Utils.log(new Exception(), "[doInBackground]"); String search = params[0]; List&lt;EntryVO&gt; entryVOs = new SearchYoutubeAPI().searchYoutube(search); Utils.log(new Exception(), "[entryVOs]" + entryVOs.size()); return entryVOs; } } </code></pre> <p>to run in Activity, it works well with 2.2 also.</p> <p>Could you please tell me what's wrong with my code.......</p> <p>Thanks so much,</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload