android-asynctask

how can i update view when fragment change?

馋奶兔 提交于 2020-01-22 02:19:12
问题 i have a activity that have 2 sherlockfragment in this The first two pages display fragments with custom list views which are built from xml from server using AsyncTask. However, when the app runs, only one list view is displayed, the other page is just blank public class VpiAbsTestActivity extends SherlockFragmentActivity { private static final String[] CONTENT = new String[] { "1","2"}; TestFragmentAdapter mAdapter; ViewPager mPager; PageIndicator mIndicator; protected void onCreate(Bundle

AsyncTask never executes onPostExecute

风流意气都作罢 提交于 2020-01-21 12:42:53
问题 I am trying to execute the following AsyncTask : private class TimeUpdateTask extends AsyncTask<List<mObject>, Integer, Void> { @Override protected Void doInBackground(List<mObject>... params) { mObject o; int i; int numChecked = 0; List<mObject> mObjects = params[0]; while(true) { if (isCancelled()) { Log.w("TAG", "task interrumped"); return null; } for (i=0 ; i < mObjects.size() ; i++) { o = mObjects.get(i); if (!o.isChecked()) { o.calculateProgress(); if (o.isChecked()) { numChecked++; } }

Can somebody explain how to use ASyncTask with Android?

。_饼干妹妹 提交于 2020-01-21 09:53:48
问题 I've been doing a bunch of research and looking over the documentation for ASyncTask in Android, but I just can't seem to wrap my head around it. I simply want to run some methods while a fragment is visible in an application, but in order to more easily do that, I think I should be using ASyncTask. My example code is as follows: private class syncExample extends ASyncTask <Void, Void, Void> { @Override protected void onPreExecute() { } @Override protected void doInBackground(Void... voids) {

Async task not supporting in android 9.0 (Pie)

Deadly 提交于 2020-01-21 05:26:47
问题 I was working on my code. it was working fine on version 8(Oreo) after that I got an update of android v 9.0 (Pie) and the app stopped working suddenly. after checking I got a error message om my Asyn task stating the below error: E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1 Process: com.global.exch, PID: 25112 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:354) at java.util.concurrent.FutureTask.finishCompletion

Call a Fragment in Asyncktask OnPostExecute method

浪子不回头ぞ 提交于 2020-01-17 15:17:33
问题 I have a little problem, I have a AsyncTask where I get a response from the server if the user is registered or not, would that after the call, if the user accesses exist in another fragment, also by storing in a preferences user email, however I have problem when I call getFragmentManager() , could someone help me out? Thank you. This is my code. LoginTask.java public class LoginTask extends AsyncTask<String, Void, User> { public LoginTask() { } @Override protected User doInBackground(String

AndroidHttpClient.execute is returning httpresponse as null [duplicate]

爷,独闯天下 提交于 2020-01-17 14:34:13
问题 This question already has answers here : How to connect to my http://localhost web server from Android Emulator in Eclipse (10 answers) Closed 6 years ago . I am trying to access my uri from the below code AsyncTask asyncTask = new AsyncTask() { @Override protected Object doInBackground(Object... params) { AndroidHttpClient httpClient = AndroidHttpClient.newInstance(""); HttpUriRequest uriGetRequest = new HttpGet("http://localhost:8080/restsql-0.8.6/res/"); HttpResponse httpResponse = null;

List view showing images jumbled after downloading images using asynctask

五迷三道 提交于 2020-01-17 13:49:33
问题 I have used the async task to download the data and then showing those images in the list view I used the cache to store the images as they are repeating but not in an order. But the images gets jumbled up and sometimes they don't download. I tried searching this, but couldn't find that. This was one of mine dream company question and i didn't clear because of this. Please help me around. public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity";

Execute “doInBackground()” showing IllegalArgumentException

倾然丶 夕夏残阳落幕 提交于 2020-01-17 13:47:32
问题 My app downloads titles from the news webpage and display them in a listview, kinda a RSSReader, now when i try to run it but it shows error. Code:- public class RSSReaderActivity extends ListActivity { List headlines, links; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); new DoSomeTask().execute(); } // DoSomeTask class will do all the work on another thread so there will be no // ANR and UI hanging. private

Android - How to pass another activity application context from java class extends fragments to asynctask?

夙愿已清 提交于 2020-01-17 05:29:52
问题 Hi I am trying to make application that has view pager and tablayout. So when I choose 'friends' tab layout it will call java class named FragFriends.java, In this class I want to inflate layout where recycler view adapter is filled with data from database that I retrieve using asynctask method in class PHPuserlist.java However my application suddenly stopped Here is the the FragFriends.java public class FragmentFriends extends Fragment { @Nullable @Override public View onCreateView

Using a handler / AsyncTask or similar to run a networking task

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-17 03:34:27
问题 i am aware that the error is occurring because im trying to put a network call on the main thread so i need to use a handler or asynctask however i dont seem to be able to get it right this is the code im trying to get to work try { // Create a URL for the desired page URL url = new URL("http://darkliteempire.gaming.multiplay.co.uk/testdownload.txt"); // Read all the text returned by the server BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String str; while