title: how to put progress bar in starting of a new activity
body: <p>i Have two activities <strong>A</strong> and <strong>B</strong>. i used intent to jump from <strong>A</strong> to <strong>B</strong>. now in <strong>B</strong>.</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.list_main);
  
     LoadData();
  }
  </code></pre>
  
  <p>now in <code>LoadData()</code>, i have to load a lot of data, wo i want that when it B starts, it show a <strong>Progress bar</strong> and after loading the data, it jumps back to my activity B. how can I do this???
  here is my load function</p>
  
  <pre><code>public void LoadData(Context context)
      {
  
          String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '"
                  + ("1") + "'";
          String sortOrder = ContactsContract.Contacts.DISPLAY_NAME
                  + " COLLATE LOCALIZED ASC";
  
          ContentResolver cr = getContentResolver();
          // ContactsContract.Contacts.
          // Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,
          // null, null, ContactsContract.Contacts.DISPLAY_NAME);
          // Find the ListView resource.
  
          Cursor cur;
          cur = context.getContentResolver().query(
                  ContactsContract.Contacts.CONTENT_URI,
                  null,
                  selection + " AND "
                          + ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1",
                  null, sortOrder);
  
          mainListView = (ListView) findViewById(R.id.mainListView);
  
          // When item is tapped, toggle checked properties of CheckBox and
          // Planet.
          mainListView
                  .setOnItemClickListener(new AdapterView.OnItemClickListener()
                  {
                      public void onItemClick(AdapterView&lt;?&gt; parent, View item,
                              int position, long id)
                      {
                          ContactsList planet = listAdapter.getItem(position);
                          planet.toggleChecked();
                          PlanetViewHolder viewHolder = (PlanetViewHolder) item
                                  .getTag();
                          viewHolder.getCheckBox().setChecked(planet.isChecked());
                      }
                  });
  
          // Create and populate planets.
          planets = (ContactsList[]) getLastNonConfigurationInstance();
          // planets = new Planet[10];
          // planets.Add("asdf");
          ArrayList&lt;ContactsList&gt; planetList = new ArrayList&lt;ContactsList&gt;();
          String phoneNumber = null;
          String phoneType = null;
  
          count = cur.getCount();
          contacts = new ContactsList[count];
  
          if (planets == null)
          {
              if (cur.getCount() &gt; 0)
              {
                  planets = new ContactsList[cur.getCount()];
                  int i = 0;
                  //
                  while (cur.moveToNext())
                  {
                      String id = cur.getString(cur
                              .getColumnIndex(ContactsContract.Contacts._ID));
                      String name = cur
                              .getString(cur
                                      .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
                      if (Integer
                              .parseInt(cur.getString(cur
                                      .getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) &gt; 0)
                      {
                          // Query phone here. Covered next
                          Cursor pCur = cr
                                  .query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                                          null,
                                          ContactsContract.CommonDataKinds.Phone.CONTACT_ID
                                                  + " = ?", new String[]
                                          { id }, null);
  
                          // WHILE WE HAVE CURSOR GET THE PHONE NUMERS
                          while (pCur.moveToNext())
                          {
                              // Do something with phones
                              phoneNumber = pCur
                                      .getString(pCur
                                              .getColumnIndex(ContactsContract.CommonDataKinds.Phone.DATA));
  
                              phoneType = pCur
                                      .getString(pCur
                                              .getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
  
                              Log.i("Pratik", name + "'s PHONE :" + phoneNumber);
                              Log.i("Pratik", "PHONE TYPE :" + phoneType);
                          }
                          pCur.close();
                      }
  
                      if (phoneNumber != null
                              &amp;&amp; !planetList.contains(new ContactsList(name,
                                      phoneNumber)))
                      {
                          planets = new ContactsList[]
                          { new ContactsList(name, phoneNumber) };
  
                          contacts[i] = planets[0];
                          planetList.addAll(Arrays.asList(planets));
                      }
                      phoneNumber = null;
                      i++;
                  }
              }
  
              // for (int i = 0; i &lt; count; i++)
              // {
              // Log.d("New Selected Names : ", contacts[i].getName());
              // }
          }
  
          // Set our custom array adapter as the ListView's adapter.
          listAdapter = new PlanetArrayAdapter(this, planetList);
          mainListView.setAdapter(listAdapter);
  
          Adapter adptr;
          adptr = mainListView.getAdapter();
      }
  </code></pre>