android-asynctask

fatal exception : asynctask #1 doInBackground

跟風遠走 提交于 2020-01-24 20:31:06
问题 Im new to android programming and i cant pinpoint which triggers the error. i am having this errors: 10-29 02:34:17.989: E/AndroidRuntime(853): FATAL EXCEPTION: AsyncTask #1 10-29 02:34:17.989: E/AndroidRuntime(853): java.lang.RuntimeException: An error occured while executing doInBackground() 10-29 02:34:17.989: E/AndroidRuntime(853): at android.os.AsyncTask$3.done(AsyncTask.java:299) 10-29 02:34:17.989: E/AndroidRuntime(853): at java.util.concurrent.FutureTask.finishCompletion(FutureTask

How to return data from asynctask

五迷三道 提交于 2020-01-24 19:53:28
问题 i have a class extends asynctask private class taskMK extends AsyncTask<Void,Void,JSONObject>{ String url; JSONObject json; public taskMK(String tr){ this.url = tr; } @Override protected JSONObject doInBackground(Void... params) { JSONParser jsonParser = new JSONParser(); JSONObject json = jsonParser.getJSONFromURL(url); return json; } @Override protected void onPostExecute(JSONObject result) { this.json = result; } @Override protected void onPreExecute() { // TODO Auto-generated method stub

java.lang.ClassNotFoundException in AsyncTask on API 16 to 19

自闭症网瘾萝莉.ら 提交于 2020-01-24 10:36:49
问题 I have an error that only happens in android 4 (API 16 to 19). I use the following code private class AcceptBooking extends AsyncTask<String, Void, String> { int response; @Override protected void onPreExecute() { } @Override protected void onPostExecute(String s) { switch (response){ case NO_UPDATE: startApp(); break; case SUGEST_UPDATE: adviceUpdate(); break; case FORCE_UPDATE: forceUpdate(); break; default: startApp(); break; } } @Override protected String doInBackground(String... params)

Android showing Image in Gallery which needs to be downloaded from Internet

≡放荡痞女 提交于 2020-01-24 10:12:51
问题 I am writing an application in which I need to show images from the URLs. Now suppose I have to show 100 images, one after the another and each photo needs to be downloaded from the internet. I am using the Gallery View to show the images, but the problem is when I pass the URL to getView function it starts downloading all the 100 images (yes in Async Task only), but downloading 100 images slows down the system. What I want to achieve is, when i move right, my program should pick the url and

How can I make sure my threads / processes are running on different cores

∥☆過路亽.° 提交于 2020-01-23 18:58:07
问题 I'm trying to measure performance improvement of my code when I run my multithreaded android app on a multicore device (like the S3) versus a single core android device. To measure performance, I run the tasks sequentially versus in parallel. I've implemented normal Java threads, which didn't seem to make a difference. I thus tried AsynchTask, but I only got a little bit of performance improvement. Can you let me know how I can write code that makes sure that each of my tasks / threads are

RecyclerView, GridLayoutManager and dynamic Spans count

泄露秘密 提交于 2020-01-23 12:18:49
问题 I encountered a strange bug with the recyclerview . I set and resize spans dynamically to fit with the informations downloaded from an AsyncTask. Sometimes it doesn't display properly. It seems like it displays over the screen.! Then after one or more reload it displays correctly. It seems to go out the screen but I can't figure out why. Here is my adapter: public class ScheduleAdapter extends RecyclerView.Adapter<ScheduleAdapter.ViewHolder> { private List<Schedule> mDataset; /** * First

Threads and Asynctask task use for httppost

不羁的心 提交于 2020-01-23 11:02:20
问题 Friends ,i need help to android httppost data to server using Asynctask or Threads I need to send data to my server when i click post button.But when i click it app need to go to next page and data need to send through as background process.I'm new to Android.I don't know what is exactly use for this kind of task (Threads or Asyanctask). I tried this code but it will give me exception error public void startProgress(final String name) { // Do something long Runnable runnable = new Runnable()

How to write JSON data into excel or csv format Android?

泪湿孤枕 提交于 2020-01-23 04:26:28
问题 I am trying to dump my JSON response into excel sheet with .csv file after getting response from server. I have tried with poi-3.7.jar and poi-ooxml-3.11.jar libraries. But I am getting an empty excel sheet. Please check my below code for more reference. My JSON URL http://vehiclerescue.in/ideadarpan_beta/api/reportApp/get_tsm_data Code how I created rows: try { fis = new FileInputStream(new File("C:\\File\\excel.xlsx")); workbook = new XSSFWorkbook(fis); sheet = workbook.getSheetAt(0); /

How to execute onMapReady() callback after all the AsyncTasks are completed?

放肆的年华 提交于 2020-01-23 04:18:28
问题 I am having trouble with my code where i have my Activity which i use to call google api's and retrieve jsons, deserialize them and use it's Polylines to draw on the map. The problem is that getMapAsync() which sends the callback for onMapReady() (which is used to create the map) is executed immediately after executing my Async Tasks which retrieves necessary data to create the map. How can i make this happen without stopping the UI thread? I tried doing this calling .execute.get() which

AsyncTask : passing value to an Activity (onCreate method )

你离开我真会死。 提交于 2020-01-22 15:45:28
问题 Update1 activity: public Integer _number = 0; @Override public void onCreate(Bundle savedInstanceState) { if (_number >0) { Log.d("onSuccessfulExecute", ""+_number); } else { Log.d("onSuccessfulExecute", "nope empty songs lists"); } } public int onSuccessfulExecute(int numberOfSongList) { _number = numberOfSongList; if (numberOfSongList >0) { Log.d("onSuccessfulExecute", ""+numberOfSongList); } else { Log.d("onSuccessfulExecute", "nope empty songs lists"); } return numberOfSongList; } end