I am new to android. I am trying to build a simple android application: User clicks the button and a progress dialog appears for 5 seconds. I used ProgressDialog.show() and got a problem with the context parameter. Here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <Button
        android:id="@+id/btnDialog2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/btnDialog2" />
</LinearLayout>
And here is my code:
public class Dialog22Activity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button btnDialog2 = (Button)findViewById(R.id.btnDialog2);
        btnDialog2.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                final ProgressDialog dialog = ProgressDialog.show(getBaseContext(), 
                        "Progress dialog", "Loading...", true);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            Thread.sleep(5000);
                            dialog.dismiss();
                        } catch (InterruptedException e) {
                        }
                    }
                }).start();
            }           
        });
    }
}
If i change the context parameter of ProgressDialog.show() from getBaseContext() to v.getContext() my program run normally. So I wanna ask what is the meanning of context parameter here? Thanks for your helps.
 
     
     
     
     
     
     
     
    