Android Open Source - cpustats My Async Task






From Project

Back to project page cpustats.

License

The source code is released under:

Apache License

If you think the Android project cpustats listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package jp.takke.cpustats;
/*from   ww w  .j  av  a2  s.co  m*/
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.concurrent.Executor;

import android.os.AsyncTask;

public abstract class MyAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> {
    
    @SuppressWarnings("unchecked")
    public final AsyncTask<Params, Progress, Result> parallelExecute(Params... params) {
        
        if (android.os.Build.VERSION.SDK_INT >= 13) {
            // Android 3.2 ???????????????????????????????????????????????????
            // @see http://daichan4649.hatenablog.jp/entry/20120125/1327467103
            
            // ?????? Android 1.6 ???????????????????????????????????????????
//          return super.executeOnExecutor(executor, params);
            
            try {
                final Field f = AsyncTask.class.getField("THREAD_POOL_EXECUTOR");
                final Executor executor = (Executor) f.get(null);
                
                final Method m = this.getClass().getMethod("executeOnExecutor", new Class[]{
                        Executor.class, Object[].class });
                
                return (AsyncTask<Params, Progress, Result>) m.invoke(this, executor, params);
        
            } catch (Exception e) {
                MyLog.e(e);
            }
        }
        
        return super.execute(params);
    }
}




Java Source Code List

jp.takke.cpustats.BootReceiver.java
jp.takke.cpustats.C.java
jp.takke.cpustats.ConfigActivity.java
jp.takke.cpustats.MyAsyncTask.java
jp.takke.cpustats.MyLog.java
jp.takke.cpustats.MyUtil.java
jp.takke.cpustats.PreviewActivity.java
jp.takke.cpustats.QuadResourceUtil.java
jp.takke.cpustats.QuadResourceUtil.java
jp.takke.cpustats.ResourceUtil.java
jp.takke.cpustats.UsageUpdateService.java