Back to project page android-sdk.
The source code is released under:
Copyright (c) 2013 Adcash OU. All rights reserved under Creative Commons Attribution 3.0 Unported http://creativecommons.org/licenses/by/3.0/ Redistribution and use in source and binary forms, with or...
If you think the Android project android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.adcash.mobileads.util; //w w w. j a va 2s . c o m import android.os.AsyncTask; import java.util.concurrent.*; import static com.adcash.mobileads.util.Reflection.MethodBuilder; import static com.adcash.mobileads.util.VersionCode.ICE_CREAM_SANDWICH; import static com.adcash.mobileads.util.VersionCode.currentApiLevel; public class AsyncTasks { public static <P> void safeExecuteOnExecutor(AsyncTask<P, ?, ?> asyncTask, P... params) throws Exception { if (asyncTask == null) { throw new IllegalArgumentException("Unable to execute null AsyncTask."); } if (currentApiLevel().isAtLeast(ICE_CREAM_SANDWICH)) { Executor threadPoolExecutor = (Executor) AsyncTask.class.getField("THREAD_POOL_EXECUTOR").get(AsyncTask.class); new MethodBuilder(asyncTask, "executeOnExecutor") .addParam(Executor.class, threadPoolExecutor) .addParam(Object[].class, params) .execute(); } else { asyncTask.execute(params); } } }