List of usage examples for android.os AsyncTask THREAD_POOL_EXECUTOR
Executor THREAD_POOL_EXECUTOR
To view the source code for android.os AsyncTask THREAD_POOL_EXECUTOR.
Click Source Link
From source file:com.commonsware.empub.ModelFragment.java
@TargetApi(11) 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 {//from w w w . jav a 2 s .c om task.execute(params); } }
From source file:com.bukanir.android.activities.MovieActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate"); super.onCreate(savedInstanceState); supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.activity_movie); fragmentManager = getSupportFragmentManager(); final ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); if (savedInstanceState != null) { movie = (Movie) savedInstanceState.getSerializable("movie"); } else {// w w w .ja va 2s. com Bundle bundle = getIntent().getExtras(); movie = (Movie) bundle.get("movie"); movieTask = new MovieTask(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { movieTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { movieTask.execute(); } } }
From source file:com.prey.services.PreyRegistrationIntentService.java
private void sendRegistrationToServer(String token) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) new UpdateCD2MId().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, token, getApplicationContext()); else/*from w ww.ja v a 2 s .co m*/ new UpdateCD2MId().execute(token, getApplicationContext()); }
From source file:com.intel.iotkitlib.LibModules.ParentModule.java
protected boolean invokeHttpExecuteOnURL(String url, AsyncTask<String, Void, CloudResponse> httpTask, String taskDescription) { //try {//w w w . j av a 2 s . com //httpTask.execute(url).get(); if (url == null) { Log.i(TAG, "Http request Url Cannot be null"); } httpTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, url); return true; //} /*catch (InterruptedException e) { Log.e(taskDescription, "InterruptedException", e); return false; } catch (ExecutionException e) { Log.e(taskDescription, "ExecutionException", e); return false; }*/ }
From source file:com.grabtaxi.roadboardscan.zxing.InactivityTimer.java
/** * ??// w w w . j ava 2s. c om */ public synchronized void onActivity() { cancel(); inactivityTask = new InactivityAsyncTask(); inactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null); }
From source file:de.enlightened.peris.ActiveList.java
private void loadUserList() { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { new DownloadUserlistTask(this.profileSelected).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else {/*from ww w . ja va2s.co m*/ new DownloadUserlistTask(this.profileSelected).execute(); } }
From source file:org.appspot.apprtc.util.ThumbnailsCacheManager.java
static public void ThumbnailsCacheManagerInit(Context context) { synchronized (mThumbnailsDiskCacheLock) { mAppContext = context;//w w w . java 2 s . c om if (mThumbnailCacheStarting) { // initialise thumbnails cache on background thread try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { new InitDiskCacheTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null); } else { new InitDiskCacheTask().execute(); } } catch (RejectedExecutionException e) { e.printStackTrace(); } } } }
From source file:com.cw.litenote.operation.import_export.Import_fileView.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.import_sd_file_view, container, false); System.out.println("Import_fileView / onCreate"); mTitleViewText = (TextView) rootView.findViewById(R.id.view_title); mBodyViewText = (TextView) rootView.findViewById(R.id.view_body); // getActivity().getActionBar().setDisplayShowHomeEnabled(false); Import_fileView_asyncTask task = null; if (savedInstanceState == null) { task = new Import_fileView_asyncTask(MainAct.mAct, rootView, filePath); task.enableSaveDB(false);// view task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else {/* w w w.j ava2 s . com*/ mFile = new File(filePath); mTitleViewText.setText(mFile.getName()); mBodyViewText.setText(task.importObject.fileBody); } int style = 2; //set title color mTitleViewText.setTextColor(ColorSet.mText_ColorArray[style]); mTitleViewText.setBackgroundColor(ColorSet.mBG_ColorArray[style]); //set body color mBodyViewText.setTextColor(ColorSet.mText_ColorArray[style]); mBodyViewText.setBackgroundColor(ColorSet.mBG_ColorArray[style]); // back button Button backButton = (Button) rootView.findViewById(R.id.view_back); backButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_menu_back, 0, 0, 0); // import button Button confirmButton = (Button) rootView.findViewById(R.id.view_confirm); confirmButton.setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.ic_menu_revert, 0, 0, 0); confirmButton.setText(R.string.config_import); // delete button Button deleteButton = (Button) rootView.findViewById(R.id.view_delete); deleteButton.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_delete, 0, 0, 0); // do cancel backButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { backToListFragment(); } }); // delete the file whose content is showing deleteButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Util util = new Util(getActivity()); util.vibrate(); mFile = new File(filePath); String fileName = mFile.getName(); AlertDialog.Builder builder1 = new AlertDialog.Builder(getActivity()); builder1.setTitle(R.string.confirm_dialog_title) .setMessage(getResources().getString(R.string.confirm_dialog_message_file) + " (" + fileName + ")") .setNegativeButton(R.string.confirm_dialog_button_no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog1, int which1) { /*nothing to do*/} }) .setPositiveButton(R.string.confirm_dialog_button_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog1, int which1) { mFile.delete(); // refresh directory list backToListFragment(); String dirString = new File(filePath).getParent(); File dir = new File(dirString); Import_filesList fragment = ((Import_filesList) getActivity() .getSupportFragmentManager().findFragmentByTag("import")); fragment.getFiles(dir.listFiles()); } }) .show(); } }); // confirm to import view to DB confirmButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Import_fileView_asyncTask task = new Import_fileView_asyncTask(MainAct.mAct, rootView, filePath); task.enableSaveDB(true);//confirm task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); return rootView; }
From source file:com.aniruddhc.acemusic.player.Services.PinGMusicSongsService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { //The initial notification will display a "Starting download" message + indeterminate progress bar. mNotifyManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); mBuilder = new NotificationCompat.Builder(mContext); mBuilder.setContentTitle(mContext.getResources().getString(R.string.starting_download)); mBuilder.setTicker(mContext.getResources().getString(R.string.starting_download)); mBuilder.setSmallIcon(R.drawable.pin_light); mBuilder.setProgress(0, 0, true);//from w w w . j a v a 2 s . co m mNotifyManager.notify(notificationID, mBuilder.build()); //Call the AsyncTask that kicks off the pinning process. AsyncPinSongsTask task = new AsyncPinSongsTask(mContext); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (String[]) null); return START_STICKY; }
From source file:com.dnielfe.manager.dialogs.UnpackDialog.java
@Override public Dialog onCreateDialog(Bundle state) { final Activity a = getActivity(); // Set an EditText view to get user input final EditText inputf = new EditText(a); inputf.setHint(R.string.enter_name); inputf.setText(Browser.mCurrentPath); final AlertDialog.Builder b = new AlertDialog.Builder(a); b.setTitle(R.string.extractto);//from w ww . j av a2 s . c om b.setView(inputf); b.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String newpath = inputf.getText().toString(); dialog.dismiss(); if (ext.equals("zip")) { final UnZipTask task = new UnZipTask(a); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath); } else if (ext.equals("rar")) { final UnRarTask task = new UnRarTask(a); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath); } } }); b.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); return b.create(); }