Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8924945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:33:47+00:00 2026-06-15T07:33:47+00:00

A small part of my application checks if files exist on the user’s device.

  • 0

A small part of my application checks if files exist on the user’s device. The list of files is potentially quite long – apparently long enough to cause ANR’s with a few users. A thousand files is by no means impossible.

The code is quite simple:

new File(fileUrl).exists()

I’m currently doing it on the main thread, as I need the operations to be blocking. I could do it using an AsyncTask class and then continue the rest of the work once it’s done, but I’m wondering if that’s a valid cause?

All the work is being done in a background Service, if that changes anything. I’m also potentially going to experience orientation changes, and that might be annoying with AsyncTask. Would a Handler be better?

So, to sum things up: Should I do use an AsyncTask for a potentially long-running operation in a background Service, where orientation changes may occur?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:33:49+00:00Added an answer on June 15, 2026 at 7:33 am

    Firstly, a Service isn’t affected by orientation change – it’s only the currently running Activity class which is destroyed / recreated.

    Secondly, an AsyncTask isn’t of much advantage in a Service as it’s designed to be able to interact with the UI. It would give the advantage of doing work on a separate thread but the rest of the methods would basically be redundant.

    I’d recommend using an IntentService which manages its own worker thread to do work. See the IntentService documentation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in my application there is a small part of function,in which it will read
I need to implement a small part of my application logic in native code.
My ASP.NET MVC application is a small part of a bigger ColdFusion app that
I am developing a small part of a PHP application with some python code.
I am designing a pretty complex WPF application. A relatively small part of the
I want to develop an application, the small part of which will search the
I have an application that I have to run as Administrator. One small part
As part of my application, I'm putting together a set of small Dom nodes
I have a requirement to change a very small part of the WPF ComboBox's
I'm part of a small development team and we are currently moving from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.