Infoware
Infoware

Reputation: 158

Delay between One Activity to Another Activity

I develop one application in Android. Which contains so many data (String) and images. string data are come from database and images comes from /res folder.

In My Application First Activity shows categories of books. Then i select any one of them then jump to the next activity which display all books images and brief description of selected category these all data are coming from database with Query operation and fill custom list view with ArrayAdapter. These is working and display all the things which i want.

but the problem is that when i click on category from one activity it takes more than 1 minute time to display second activity (Detail Information of Selected Category). So, Here user is stuck. It is bad for my application.

So is there any way to solve these or any Idea to display Activity Loading Process between One Activity to Second Activity ?

Thanks in Advance.

Please Help Me to solve these.

Upvotes: 3

Views: 1250

Answers (3)

Sanket Kachhela
Sanket Kachhela

Reputation: 10866

use AsyncTask as

public class My_Game_Task extends AsyncTask<String, Void, Void> {


        @Override
        protected void onPreExecute() {
            //put a preloder
            super.onPreExecute();
        }

        @Override
        protected Void doInBackground(String... arg0) {
            // TODO Auto-generated method stub

            find data from database

            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            dismiss preloader
                            set adapter here
            super.onPostExecute(result);

        }

    }

call on oncreate as new My_Game_Task().execute(); this will immediately show the next activity and will show a preloader

Upvotes: 6

Pir Fahim Shah
Pir Fahim Shah

Reputation: 10623

Try this one it will make a delay of one second before going to execute any other operations,

  try {
    Thread.sleep(1000);
      } catch (InterruptedException e)
      {
    e.printStackTrace();
       }

Upvotes: -1

sankettt
sankettt

Reputation: 2417

First of all where are you testing the app.. if its on emulator then check it on actual device you would get a idea how much delay takes place actually.! I had similar problem it takes minutes on emulator but runs amazingly on actual device.It takes just 1 second to display..

Upvotes: 0

Related Questions