當前位置: 首頁>>代碼示例>>Java>>正文


Java AsyncTask.executeOnExecutor方法代碼示例

本文整理匯總了Java中android.os.AsyncTask.executeOnExecutor方法的典型用法代碼示例。如果您正苦於以下問題:Java AsyncTask.executeOnExecutor方法的具體用法?Java AsyncTask.executeOnExecutor怎麽用?Java AsyncTask.executeOnExecutor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.AsyncTask的用法示例。


在下文中一共展示了AsyncTask.executeOnExecutor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: executeTask

import android.os.AsyncTask; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static <A, B, C> void executeTask(AsyncTask<A, B, C> task, A... params ) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
    }
    else {
        task.execute(params);
    }
}
 
開發者ID:ceji-longquan,項目名稱:ceji_android,代碼行數:10,代碼來源:PlatformUtil.java

示例2: sendMessage

import android.os.AsyncTask; //導入方法依賴的package包/類
public void sendMessage(final String message){

        if (mRun) {

            AsyncTask<Void, Void, Boolean> sendThread = new AsyncTask<Void, Void, Boolean>() {
                @Override
                protected Boolean doInBackground(Void... params) {

                    Log.d("ConnectionService", "Sending: " + message);
                    if (out != null && !out.checkError()) {
                        out.println(message);
                        out.flush();
                    }



                    return null;
                }
            };
            sendThread.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
    }
 
開發者ID:Thizizmyname,項目名稱:MyPlace,代碼行數:23,代碼來源:ConnectionService.java

示例3: initializeCircumvention

import android.os.AsyncTask; //導入方法依賴的package包/類
private void initializeCircumvention() {
    AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
      @Override
      protected Void doInBackground(Void... params) {
        if (new SignalServiceNetworkAccess(ApplicationContext.this).isCensored(ApplicationContext.this)) {
          try {
//NOGMS            ProviderInstaller.installIfNeeded(ApplicationContext.this);
          } catch (Throwable t) {
            Log.w(TAG, t);
          }
        }
        return null;
      }
    };

    if (Build.VERSION.SDK_INT >= 11) task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    else                             task.execute();
  }
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:19,代碼來源:ApplicationContext.java

示例4: decodeFileAtAsync

import android.os.AsyncTask; //導入方法依賴的package包/類
private void decodeFileAtAsync(
		final int index,
		final int size,
		final OnBitmapLoadedListener listener) {
	AsyncTask<Void, Void, OrientedBitmap> task =
			new AsyncTask<Void, Void, OrientedBitmap>() {
		@Override
		public OrientedBitmap doInBackground(Void... nothings) {
			return decodeFileAt(index, size);
		}

		@Override
		protected void onPostExecute(OrientedBitmap orientedBitmap) {
			if (orientedBitmap != null) {
				listener.onBitmapLoaded(
						orientedBitmap.bitmap,
						orientedBitmap.orientation);
			} else {
				listener.onBitmapLoaded(null, 0);
			}
		}
	};

	if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
		// from DONUT until HONEYCOMB AsyncTask had a pool of threads
		// allowing multiple tasks to operate in parallel
		task.execute();
	} else {
		// starting with HONEYCOMB, tasks are executed on a single
		// thread (what would mean this task would block all other
		// AsyncTask's) unless executeOnExecutor() is used
		task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
	}
}
 
開發者ID:markusfisch,項目名稱:SwipeImageView,代碼行數:35,代碼來源:SwipeImageView.java

示例5: loadMusic

import android.os.AsyncTask; //導入方法依賴的package包/類
public static void loadMusic(final Context context, final MusicLoaderListener loaderListener) {

        final AsyncTask<Void, Void, Void> loadTask = new AsyncTask<Void, Void, Void>() {
            String[] resp = {"", ""};
            List<MediaMetaData> listMusic = new ArrayList<>();

            @Override
            protected Void doInBackground(Void... voids) {
                //resp = getDataResponse();
                String response = loadJSONFromAsset(context);
                listMusic = getMusicList(response, "music");
                return null;
            }

            @Override
            protected void onPostExecute(Void aVoid) {
                super.onPostExecute(aVoid);

                if (loaderListener != null && listMusic != null && listMusic.size() >= 1) {
                    loaderListener.onLoadSuccess(listMusic);
                } else {
                    loaderListener.onLoadFailed();
                }
            }
        };
        loadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
 
開發者ID:dibakarece,項目名稱:DMAudioStreamer,代碼行數:28,代碼來源:MusicBrowser.java

示例6: executeAsyncTask

import android.os.AsyncTask; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private < T > void executeAsyncTask(AsyncTask< T, ?, ? > asyncTask, T... params) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
    } else {
        asyncTask.execute(params);
    }
}
 
開發者ID:kerick-jeff,項目名稱:MyBP,代碼行數:9,代碼來源:DatabaseTable.java

示例7: execUi

import android.os.AsyncTask; //導入方法依賴的package包/類
public static <A, B, C> void execUi(AsyncTask<A, B, C> task, A... params) {
    if (task != null) {
        if (VERSION.SDK_INT < 11) {
            task.execute(params);
        } else {
            task.executeOnExecutor(uiExecutor, params);
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:10,代碼來源:ThreadUtil.java

示例8: executeAsyncTask

import android.os.AsyncTask; //導入方法依賴的package包/類
/**
 * Execute async task on single thread Executer or cached thread pool Executer.
 *
 * @param singleThread True if needs to be executed on single thread Executer, otherwise it will
 * use cached thread pool Executer.
 * @param task Async task to execute.
 * @param params Params.
 */
public static <T> void executeAsyncTask(boolean singleThread, AsyncTask<T, ?, ?> task,
    T... params) {
  if (singleThread) {
    task.executeOnExecutor(singleThreadExecutor, params);
  } else {
    task.executeOnExecutor(asyncExecutor, params);
  }
}
 
開發者ID:Leanplum,項目名稱:Leanplum-Android-SDK,代碼行數:17,代碼來源:Util.java

示例9: executeAsyncTask

import android.os.AsyncTask; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
static public <T> void executeAsyncTask(AsyncTask<T, ?, ?> task, T... params) {
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
	}
	else {
		task.execute(params);
	}
}
 
開發者ID:SalmanTKhan,項目名稱:MyAnimeViewer,代碼行數:10,代碼來源:AsyncTaskUtils.java

示例10:

import android.os.AsyncTask; //導入方法依賴的package包/類
/**
 * Concurrently executes AsyncTask on any Android version
 * @param task to execute
 * @param params for task
 * @return executing AsyncTask 
 */
@SuppressLint("NewApi") 
public static <Params, Progress, Result> AsyncTask<Params, Progress, Result> 
	executeConcurrently(AsyncTask<Params, Progress, Result> task,
		Params... params) {
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		task.executeOnExecutor(concurrentExecutor, params);
	} else {
		task.execute(params);
	}
	return task;
}
 
開發者ID:SalmanTKhan,項目名稱:MyAnimeViewer,代碼行數:18,代碼來源:AsyncTaskExecutor.java

示例11: execute

import android.os.AsyncTask; //導入方法依賴的package包/類
/**
 * Execute an {@link android.os.AsyncTask} on a thread pool.
 *
 * @param task Task to execute.
 * @param args Optional arguments to pass to {@link android.os.AsyncTask#execute(Object[])}.
 * @param <T>  Task argument type.
 */
@SafeVarargs
public static <T> void execute(AsyncTask<T, ?, ?> task, T... args) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.DONUT) {
        throw new UnsupportedOperationException("This class can only be used on API 4 and newer.");
    }
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        task.execute(args);
    } else {
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, args);
    }
}
 
開發者ID:yongbeam,項目名稱:AirQuickUtils,代碼行數:19,代碼來源:AirSystem.java

示例12: async

import android.os.AsyncTask; //導入方法依賴的package包/類
public static AsyncTask async(final Runnable r, boolean multi) {
    AsyncTask<Void, Void, Void> at = new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... voids) {
            r.run();
            return null;
        }
    };
    if (multi) {
        at.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {
        at.execute();
    }
    return at;
}
 
開發者ID:quaap,項目名稱:SeafoodBerserker,代碼行數:16,代碼來源:Utils.java

示例13: runTask

import android.os.AsyncTask; //導入方法依賴的package包/類
public <T> void runTask(Uri uri, AsyncTask<T, ?, ?> task, T... args) {
  synchronized (mTasks) {
    if (!mTasks.containsKey(uri) || mTasks.get(uri).getStatus() == Status.FINISHED) {
      mTasks.put(uri, task);
      // TODO: Use different executor for different servers.
      task.executeOnExecutor(mExecutor, args);
    } else {
      Log.i(TAG,
          "Ignore this task for " + uri + " to avoid running multiple updates at the same time.");
    }
  }
}
 
開發者ID:google,項目名稱:samba-documents-provider,代碼行數:13,代碼來源:TaskManager.java

示例14: runAsyncTask

import android.os.AsyncTask; //導入方法依賴的package包/類
private AsyncTask<Void, GitHubUser, GitHubUser> runAsyncTask(AsyncTask<Void, GitHubUser, GitHubUser> task)
{
    return task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
開發者ID:twisstosin,項目名稱:Lasgithub-Android,代碼行數:5,代碼來源:MainActivity.java

示例15: runAsyncTask

import android.os.AsyncTask; //導入方法依賴的package包/類
public static AsyncTask<Void, Void, Void> runAsyncTask(AsyncTask<Void, Void, Void> task, String id)
{
    return task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
開發者ID:twisstosin,項目名稱:Lasgithub-Android,代碼行數:5,代碼來源:App.java


注:本文中的android.os.AsyncTask.executeOnExecutor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。