In "onCreate" I'm downloading data from web.The duration of downloading data is 10 sec. I wan't to have ProgressDialog while the data is downloading. Here is my code , but the ProgressDialog doesn't appear:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ProgressDialog dialog = ProgressDialog.show(Test.this, "",
"Loading. Please wait...", true);
try {
URL myURL = new URL("http://www.sample.com/");
URLConnection ucon = myURL.openConnection();
InputStream is = ucon.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(50);
int current = 0;
while((current = bis.read()) != -1){
baf.append((byte)current);
}
content= new String(baf.toByteArray());
}
catch (Exception e) {}
dialog.dismiss();
}