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 7551685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:33:35+00:00 2026-05-30T10:33:35+00:00

On Android Developer Site has said that : We shouldn’t use long operations work

  • 0

On Android Developer Site has said that : We shouldn’t use long operations work in UIThread. Instead, we should do it on another thread. At this site, they still say :

if the UI thread is blocked for more than a few seconds (about 5
seconds currently) the user is presented with the infamous
“application not responding” (ANR) dialog.

To test this statement, I make a proof. Here is my code:

package com.app;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class Example extends Activity{
    TextView  textView;
    @Override 
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        textView = new TextView(this);
        textView.setText("please wait");
        setContentView(textView);

    }

    @Override
    public void onResume(){
        super.onResume();
        try {
            Thread.sleep(8000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        textView.setText("end waiting !!!");
    }

}

As you see, I make current thread (UIThread) sleep 8 seconds. So, I think, if I run this apps, Android will notice: “application not responding”. But, I don’t see any error. Program run smoothly (and I see text “end waiting”, too).

So,who can explain for me about my code. What wrong thing I have made,please.

thanks 🙂

  • 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-05-30T10:33:37+00:00Added an answer on May 30, 2026 at 10:33 am

    @hqt in your sub-question (sorry that I cannot post comment), If you want your program terminate, after you click your button, when your button in 8-seconds-running, you should click again your button, and the “magic” will happened as you wish 🙂

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

Sidebar

Related Questions

There are many intents an Android developer can use - the ones that arrive
I understand that Android's developer site provides information on this topic. I have already
Is there something in the Android developer guidelines that disuades developers from providing the
From Android widget screen guidelines, http://developer.android.com/guide/practices/ui_guidelines/widget_design.html , we know that, home screen has 4*4
The new Android 2.1 SDK (version 7) has a new class called SignalStrength: http://developer.android.com/reference/android/telephony/SignalStrength.html
Other than the brief article at android site:- http://developer.android.com/resources/articles/contacts.html I haven't seen any docs
I've been looking at the notepad tutorial from the android developer site, I'm sorta
I've tried to implement the Google Map View tutorial on the Android developer site,
Is there something in the Android developers site that shows what is deprecated by
I was reading through the sensor event documentation on the android developer site. I

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.