android-asynctask

when switch to another fragment before completing the post execute the app gets crashed ,and show this error

孤街浪徒 提交于 2020-05-17 07:46:29
问题 class GetDashboardContentsAysnc extends AsyncTask { @Override protected void onPreExecute() { super.onPreExecute(); shimmerFrameLayout.startShimmer(); } @Override protected void onPostExecute(String s) { super.onPostExecute(s); shimmerFrameLayout.stopShimmer(); shimmerFrameLayout.setVisibility(View.GONE); if(s!=null ) { try { JSONObject jsonObj = new JSONObject(s); response = jsonObj.getString("response"); if (response.contains("success")) { listcategories.clear(); JSONArray jsonArr = jsonObj

Understanding how is this interface implemented in AsyncTask [duplicate]

前提是你 提交于 2020-05-09 17:15:37
问题 This question already has answers here : What do curly braces after a 'new' statement do? (2 answers) Can we create an instance of an interface in Java? [duplicate] (7 answers) Closed 18 days ago . I wrote a simple weather app which goes fetches data from Openweathermap's API in Json format. I used an Aynctask to fetch the data, using ideas from online (as we all do!) All works ok, but I am trying to get a better understanding of the callback implementation (like this one one at How to use

AsyncTask as kotlin coroutine

£可爱£侵袭症+ 提交于 2020-04-29 18:44:22
问题 Typical use for AsyncTask: I want to run a task in another thread and after that task is done, I want to perform some operation in my UI thread, namely hiding a progress bar. The task is to be started in TextureView.SurfaceTextureListener.onSurfaceTextureAvailable and after it finished I want to hide the progress bar. Doing this synchronously does not work because it would block the thread building the UI, leaving the screen black, not even showing the progress bar I want to hide afterwards.

I'm facing Volley Time out Error and mainThread error

和自甴很熟 提交于 2020-02-29 06:14:28
问题 I'm trying to get data to form server in Andriod app using Volley library. My data was too large when I request to fetch data but the problem was volley time out error and I also used RetryPolicy but the problem was the same. How can I fix it? I have already tried RetryPolicy and AsynTask but my issue can't resolve. Can anyone tell me how to resolve this issue? //Main Function here... protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R

Android: Best way of handling continuous pulling from server?

穿精又带淫゛_ 提交于 2020-02-29 05:15:08
问题 To start of, i should mention that i'm a newbie in Android (Not that much experience in Java at all tbh), so be easy on me. I am making an app that continuously pulls data from a server, and then returns data through a http post request. The question is, what is the best way to handle the actual pulling from the server? Should i be using AsyncTask or create another thread and let it run on that? Are there better methods for this purpose? I will be pulling data every 5 minutes. (I am aware

call AsyncTask from Broadcast receiver android

你离开我真会死。 提交于 2020-02-26 08:27:56
问题 SO currently i have an AsyncTask class that runs and POST's data to my server when I click a button(which works great). What im trying to do now is handle what happens when the user is not connected to the internet. so i have set up these classes to notify the app when internet has connected so that the data can be sent automatically to the server. AsyncTask class(inner class) private class HttpAsyncTask extends AsyncTask<String, Void, String> { ProgressDialog dialog = new ProgressDialog

Android AsyncTask method that I dont know how to solve

 ̄綄美尐妖づ 提交于 2020-02-07 03:42:17
问题 I debugged my Program and I noticed that I wasent able to run Networking on the same Thread (I searched for this Error like 2 Days because in the Virtual Device the App worked without Problems -.- ). So now I know how I must fix it but I dont have a clue how I can give some parameteres that are not all String to the doinBackground Method. My Method requires a url a method these i could access afaik with params[0] and params[1] in the doInBackground method. But whats with the List of

Optimal solution for utilizing the same AsyncTask repeatedly?

末鹿安然 提交于 2020-02-06 07:47:58
问题 I know that an AsyncTask can be run only once. I know a way around that, but I need a variable from the AsyncTask that uses complicated(?) processes. This is my code for calling the AsyncTask val thr=NewTask() thr.delegate = this button.setOnClickListener { thr.execute() } NewTask.doOnBackground() is just a normal method sending the request to the URL. onPostExecute() is a bit different: public override fun onPostExecute(result: String?) { //super.onPostExecute(result) delegate!!

Optimal solution for utilizing the same AsyncTask repeatedly?

自闭症网瘾萝莉.ら 提交于 2020-02-06 07:44:52
问题 I know that an AsyncTask can be run only once. I know a way around that, but I need a variable from the AsyncTask that uses complicated(?) processes. This is my code for calling the AsyncTask val thr=NewTask() thr.delegate = this button.setOnClickListener { thr.execute() } NewTask.doOnBackground() is just a normal method sending the request to the URL. onPostExecute() is a bit different: public override fun onPostExecute(result: String?) { //super.onPostExecute(result) delegate!!

Optimal solution for utilizing the same AsyncTask repeatedly?

六月ゝ 毕业季﹏ 提交于 2020-02-06 07:44:25
问题 I know that an AsyncTask can be run only once. I know a way around that, but I need a variable from the AsyncTask that uses complicated(?) processes. This is my code for calling the AsyncTask val thr=NewTask() thr.delegate = this button.setOnClickListener { thr.execute() } NewTask.doOnBackground() is just a normal method sending the request to the URL. onPostExecute() is a bit different: public override fun onPostExecute(result: String?) { //super.onPostExecute(result) delegate!!