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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:17:27+00:00 2026-06-14T02:17:27+00:00

i have a asyntask, and in progress update i set text a TextView, this

  • 0

i have a asyntask, and in progress update i set text a TextView, this works fine, but then i rotate the screen, the textview reset and set “”(This is the initial value), in the postupdate i have a new findviewbyid(r.id.tvProgreso); and it update the textview but the text will be same.

This is my onCreate method:

  @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_incio);

        if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {
            ActionBar actionBar = getActionBar();
            actionBar.hide();

        }
        contexto = getApplicationContext();
        datos = new ArrayList<Integer>();

        recojeDatosDeSesion(savedInstanceState);
        adaptador = new AdaptadorImagenes(contexto);

        if (getLastNonConfigurationInstance() != null) {
            adaptador = (AdaptadorImagenes) getLastNonConfigurationInstance();
        }

        // Layout
        etEmail = (EditText) findViewById(R.id.etEmail);
        etPassword = (EditText) findViewById(R.id.etPassword);
        tvProgreso = (TextView) findViewById(R.id.tvProgreso);
        listaHorizontalImagenes = (Gallery) findViewById(R.id.galeria);

        listaHorizontalImagenes.setGravity(Gravity.LEFT);
        listaHorizontalImagenes.setAdapter(adaptador);
        listaHorizontalImagenes.setSelection(0);

        btnDescargar = (Button) findViewById(R.id.btnDescargar);

        clickDescargar = new OnClickListener() {

            @Override
            public void onClick(View v) {

                if (!descargaActiva) {


                    email = etEmail.getText().toString();
                    password = etPassword.getText().toString();

                    if (validaDatos(email, password)) {

                        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                        imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                        new DescargaFotos().execute();
                        descargaActiva = true;
                        Toast.makeText(contexto, "Comienza la descarga.", Toast.LENGTH_SHORT).show();
                        tvProgreso.setText("Descargando fotos..");

                    }

                } else {
                    Toast.makeText(contexto, "Descarga en proceso", Toast.LENGTH_LONG).show();
                }
            }
        };

        if (descargaActiva)
            btnDescargar.setOnClickListener(null);
        else
            btnDescargar.setOnClickListener(clickDescargar);

    }

and the progressUpdate in asyntask

@Override
        protected void onProgressUpdate(Integer... progreso) {

            // Actualizo el progreso
            progresoImagenes = progreso[0];             
            actualizaTexto(progreso[0]);
            adaptador.addItem(progreso[0]);

        }



private void actualizaTexto(Integer progreso) {

            tvProgreso = (TextView) findViewById(R.id.tvProgreso);
            tvProgreso.setText(progreso.toString() + " de " + numeroDeFotos + " fotos.");

        }

When i debug, i see the textviex.settext with te correct text, but this not change..

  • 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-14T02:17:28+00:00Added an answer on June 14, 2026 at 2:17 am

    Rotation by default recreates your activity. It actually creates a new Activity objects, and displays that on the screen. The asynctask still refers to the old Activity which is not visible anymore, and updates the TextView in that….

    You can either handle rotation yourself, thus Activity wont be destroyed as described here, or you can constraint your activity to be only available in portrait mode (add android:screenOrientation=”portrait” to the activity tag)

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

Sidebar

Related Questions

I have AsyncTask and my progress in background is in infinite loop. But I
I have managed to use an Asynctask with an indeterminate progress bar during screen
I am trying to create downloading progress. I have my class which extends AsyncTask:
I have an AsyncTask with a textview loaded in the class so it looks
I have been using Asynctask most of time, but in the current app the
I have to download a file and I'm using this code , which is
I have a working FTP system with android, but I want to be able
this is the current state/situation: I have an Activity which binds a Service which
I have developed my first android application. What that application does: I update mysql
I have spent too many hours on this and I have so far continued

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.