android-asynctask

android.os.NetworkOnMainThreadException at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1145)

一世执手 提交于 2019-12-28 01:54:25
问题 I am developing my first Android app and had built in mostly based on research. When I try to login my user I get the android.os.NetworkOnMainThreadException error. I have read online that Async should be used to make sure that this error doesn't occur but I have no idea how to do that. Below is all my code. My User Login Form Activity: import java.util.HashMap; import org.json.JSONException; import org.json.JSONObject; import android.app.Activity; import android.content.Intent; import

android design considerations: AsyncTask vs Service (IntentService?)

十年热恋 提交于 2019-12-28 01:42:26
问题 I'm designing an android app which will need to do the following steps: user pushes a button or otherwise indicates to "sync data". sync process will use REST web services to move data to and from the server. the data will be stored locally in a sqlite database. the sync process should provide status updates/messages to the UI the user should not be allowed to wander off to other parts of the application and do more work during the sync process. The first time the sync process runs, it may

AsyncTask, must it take such a performance penalty hit…?

守給你的承諾、 提交于 2019-12-27 20:09:15
问题 I'm developing a small app that reads in specific html-pages, re-formats them and then shows them in a WebView. If I run my code in the GUI thread, the performance hit is close to negligible compared to simply letting the WebView show the original html-page. But if I'm a good boy and do like I'm told, I'm supposed to use an AsyncTask to run the code in the background so as not to freeze up the GUI during those 3-5 seconds my code does its job. Problem is... if I do so, the code takes more

Loading ListView with JSON data using AsyncTask in Android [closed]

别等时光非礼了梦想. 提交于 2019-12-26 13:50:19
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I want to parse JSON data from this url http://inspirontrance.com/tpb.json. My code works without the AsyncTask but with the AsyncTask enabled, app crashes after loading for a certain number of times. Although my codes seems ok but somehow the app freezes during the async process. Here is my code, public class

Why not do all the operations in the main thread(Android)? [closed]

此生再无相见时 提交于 2019-12-26 08:32:46
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . This is a clarifying question regarding the AsyncTask class and a specific example of using the class to do a networking operation(grabbing data). How is the onPostExecute method running synchronously after the doInBackground operation any different than having the main thread do all the work

Why not do all the operations in the main thread(Android)? [closed]

这一生的挚爱 提交于 2019-12-26 08:27:02
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . This is a clarifying question regarding the AsyncTask class and a specific example of using the class to do a networking operation(grabbing data). How is the onPostExecute method running synchronously after the doInBackground operation any different than having the main thread do all the work

Setting image from url to ImageView with AsynchTask

半世苍凉 提交于 2019-12-25 23:08:51
问题 I have an image on my website, that I want to set on my ImageView. Do to that I needed to use an asynch task. I'm doing it like below. But new getThumbnail().execute(stringThumbnail); is throwing me the error getThumbnail cannot be resolved to a type . What am I doing wrong in here? final ImageView thumbnail = (ImageView) findViewById(R.id.btnThumbnail); String stringThumbnail = "myImage.jpg"; new getThumbnail().execute(stringThumbnail); class getThumbnail extends AsyncTask<String, Void, Void

Intent in AsyncTask for FragmentPagerAdapter

有些话、适合烂在心里 提交于 2019-12-25 20:06:54
问题 I have implemented a FragmentPagerAdapter of 4-lashes, and in each of them I load a fragment with a different view. In one of them, pressing an image executed a AsyncTask to obtain a series of data from a server and loads a new class through an intent on the postExecute() method as follows: //AsyncTask private static class LoadJSON extends AsyncTask<String, Void, String> { protected void onPreExecute() { mProgressItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); mProgressItem.setVisible

Intent in AsyncTask for FragmentPagerAdapter

柔情痞子 提交于 2019-12-25 20:05:28
问题 I have implemented a FragmentPagerAdapter of 4-lashes, and in each of them I load a fragment with a different view. In one of them, pressing an image executed a AsyncTask to obtain a series of data from a server and loads a new class through an intent on the postExecute() method as follows: //AsyncTask private static class LoadJSON extends AsyncTask<String, Void, String> { protected void onPreExecute() { mProgressItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); mProgressItem.setVisible

Intent in AsyncTask for FragmentPagerAdapter

人盡茶涼 提交于 2019-12-25 20:05:17
问题 I have implemented a FragmentPagerAdapter of 4-lashes, and in each of them I load a fragment with a different view. In one of them, pressing an image executed a AsyncTask to obtain a series of data from a server and loads a new class through an intent on the postExecute() method as follows: //AsyncTask private static class LoadJSON extends AsyncTask<String, Void, String> { protected void onPreExecute() { mProgressItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); mProgressItem.setVisible