当前位置: 首页>>代码示例>>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;未经允许,请勿转载。