ProgressBar at start of application

by Pinheiro » Fri, 02 Apr 2010 18:23:51 GMT


Sponsored Links
 Hi!
I'm developing an application where at the start a file is downloaded.
To keep users happy, I want to show an indeterminate progressbar while
the file is being download.
Unfortunately, the progressbar never appears, I only get a black
screen when the file is being downloaded and then the main layout
appears. Here's the code:

        setContentView(R.layout.main);

        ProgressDialog dialog = ProgressDialog.show(
                DownloadFile.this,
                "Wait",
                "Loading");
        dialog.show(); // Stop ProgressBar

        // Download file - could take lots of time
        String str=downloadUrl(" http://somefile.com/file.zip" ;);

       dialog.cancel(); // Stop ProgressBar

 What am I missing? Do I have to create an empty layout with just a
progressbar to do this?

 Thanks in advance for any help :)

Rui Pinheiro

--



ProgressBar at start of application

by ~ TreKing » Fri, 02 Apr 2010 21:13:50 GMT


 




A background thread.

Doing what you're doing is blocking the main (UI) thread, so nothing gets
drawn until your complete all calls you're making in onCreate, including the
long, blocking call to download your file. You want to spawn a thread or
start an AyncTask that will do this work in the background and send messages
to the main (UI) thread to tell it when to show and hide the progress bar.

Read up on threads in general and AsyncTask in particular. This should be a
FAQ at this point.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
 http://sites.google.com/site/rezmobileapps/treking 

--


Sponsored Links


ProgressBar at start of application

by Pinheiro » Sat, 03 Apr 2010 00:07:27 GMT


 Ops. Thanks, TreKing!

--



Other Threads

1. Upload a valid APK ADC2

I'm keep getting "upload a valid APK" when i'm uploading my app in
ADC2 site submission.
 I followed all istructions at 
http://developer.android.com/guide/publishing/preparing.html,
then signed my application with private key (40 years due date) all
with Eclipse (Android tools\Export signed application package).
The apk work fine in my phone.
What I doing wrong?

Other info:
Cancelled all Log. references;
this is my begin manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="xxx.yyy.ADC2"
      android:versionCode="1"
      android:versionName="1.0.2">
        <uses-sdk android:minSdkVersion="3" />
    <application
                android:icon="@drawable/icon"
                android:label="@string/app_name">
....

--~--~---------~--~----~------------~-------~--~----~

2. Questions about ImageView.setImageMatrix

Hi, everyone,
I;m testing to scale an image, and I got a problem:

main.xml:
<ImageView
    android:id="@+id/iv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    />

onCreate():
iv = (ImageView) findViewById(R.id.iv);
iv.setImageResource(R.drawable.icon);

onTouchEvent():
Matrix mtrx = iv.getImageMatrix();
mtrx.postScale(2, 2);
iv.setImageMatrix(mtrx);
iv.setScaleType(ScaleType.MATRIX);
iv.invalidate();

when I touch the screen the image does scaled, but the size of
imageview does not change, so I can only see part of the image. Any
way to map the imageview to the Matrix(or the drawable)? I add
android:adjustViewBounds="true" but it not works.

--~--~---------~--~----~------------~-------~--~----~

3. Paid App Protection, a problem of the whole Android ecosphere

4. Do you got any confirmation after ADC 2 submit?

5. Any email confirmation after submit the application for ADC 2?

6. How do I delete unwanted downloads and download history

7. More than one EditText - not getting focus, no soft keyboard?