android-asynctask

optimizing bitmap loading by using aSyncTask

随声附和 提交于 2020-01-17 03:28:05
问题 I have been trying to optimize my single thread app which loads a bunch of tiles that makeup a large bitmap. The app was becoming very sluggish when it would load the new tiles into system memory. Im now looking trying to use Async Tasks for this purpose. The app detects which tile is in the top left in a method called by onDraw, creates a string that contains the path of the bitmap in the Assets folder, and then checks to see if the bitmap is null before drawing. If it is null, it will load

doInBackground run so fast when using AsyncTask in Fragment

风流意气都作罢 提交于 2020-01-17 03:08:25
问题 I have a problem so strange when using Asynctask in fragment , In onCreate of Fragment I called AsyncTask like so: @Override public void onCreate(Bundle savedInstanceState) { // Step 1 new FitnessHistoryDataAsync(getActivity()).execute(10); super.onCreate(savedInstanceState); } and the doInBackground method: @Override protected Boolean doInBackground(Integer... params) { // Step 2 Log.i("", "doInBackground"); Constants.SDK.getFitnessHistoryData(context, 10, new FitnessHistoryListener() {

Call custom ArrayAdapter method from another Activity

删除回忆录丶 提交于 2020-01-17 02:41:27
问题 I have a main activity and a ListFragment containing a custom ArrayAdapter that is a tab of that main activity. The main activity has an AsyncTask that pulls down an xml file then calls another class to parse it when the app starts. The ListFragment data comes from the parsed data that the AsyncTask. I want to be able to call the custom adapter of the ListFragment so that I can notifyDataSetChanged in the onPostExecute method of the AsyncTask. How can I accomplish this? Right now, when I open

Android notifications and vibrate from service

南楼画角 提交于 2020-01-16 19:57:26
问题 I have service, that connect to server with AsyncTask. After parsing response, i need to make notification and vibrate, but get NullpointerException. @Override protected void onPostExecute(String[] result) { ReconnectCallback(result); super.onPostExecute(result); } public void ReconnectCallback(String[] params) { Handler mHandler = new Handler(); Notification notif = new Notification(R.drawable.ic_launcher, "Connection error", System.currentTimeMillis()); Intent x = new Intent();

AsyncTask chaining in Activity (callback?)

心已入冬 提交于 2020-01-16 19:18:03
问题 I am trying to chain a few AsyncTask classes inside a single Activity , which will then show another Activity once they are all completed (successfully). Currently I am chaining them off each others' onPostExecute() method but I do not like this because it somewhat couples the implementations unnecessarily. For example, I have my ImportVideoActivity which the users enters a YouTube URL to be downloaded. To do so, I have two AsyncTask classes: YouTubeVideoInfoTask : Gets the video metadata

AsyncTask chaining in Activity (callback?)

为君一笑 提交于 2020-01-16 19:17:27
问题 I am trying to chain a few AsyncTask classes inside a single Activity , which will then show another Activity once they are all completed (successfully). Currently I am chaining them off each others' onPostExecute() method but I do not like this because it somewhat couples the implementations unnecessarily. For example, I have my ImportVideoActivity which the users enters a YouTube URL to be downloaded. To do so, I have two AsyncTask classes: YouTubeVideoInfoTask : Gets the video metadata

Create multiple layouts from JSON

纵然是瞬间 提交于 2020-01-16 15:42:22
问题 I am attempting to parse a JSON response from a PHP file and then use the data to create a series of RadioButton , EditText , CheckBox , and DropDownMenu elements inside a layout. In other words a dynamic or "on the fly" layout. I'm currently receiving the JSON I need but the app is crashing. AsyncTask class LoadAllQuestions extends AsyncTask<String, String, String> { private ProgressDialog pDialog; JSONParser jParser = new JSONParser(); JSONArray questions = null; protected void onPreExecute

Create multiple layouts from JSON

扶醉桌前 提交于 2020-01-16 15:38:40
问题 I am attempting to parse a JSON response from a PHP file and then use the data to create a series of RadioButton , EditText , CheckBox , and DropDownMenu elements inside a layout. In other words a dynamic or "on the fly" layout. I'm currently receiving the JSON I need but the app is crashing. AsyncTask class LoadAllQuestions extends AsyncTask<String, String, String> { private ProgressDialog pDialog; JSONParser jParser = new JSONParser(); JSONArray questions = null; protected void onPreExecute

Android: AsyncTask, onPostExecute starts before doInBackground has finished

人走茶凉 提交于 2020-01-16 11:20:12
问题 I had this problem a few hours ago (Android: AsyncTask, my 1st task has not finished when the other starts) I put it as solved but then I realized I had a similar problem. Here is my main class "GameActivity" public void mainmethod() Log.w("GAMEACTIVITY","actionup"); myAsyncRunnable mar = new myAsyncRunnable(GameActivity.this); mar.execute("fire"); public void doPhotoTask() { PhotoTask photoTask = new PhotoTask(camera,surfaceCamera,isPreview,holder,GameActivity.this); photoTask.execute(null);

Asynk Task calling in loop not giving the value return

一世执手 提交于 2020-01-16 09:41:42
问题 I am try to create a application that will update the weather of multiple cities .Each row will have diffrent temp so i have use a AsynkTask. But i am not able to update the UI after getting the response from the API. My Main Activity public class MainActivity extends Activity { LinearLayout depart_arrivals_details; LayoutInflater inflater; TextView depart_time, depart_airport_city, depart_airport, arrival_time, arrival_airport_city, arrival_airport, pnr_number,temprature,humidity; ImageView