I want to download an image from server, save it on the SD card, and show it. I wrote that code, but it doesn't work - there are no bugs, but I see only a black screen instead of the image.
public class Main extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    MyTask mt = new MyTask();
    mt.execute();
    Intent intent = new Intent();  
    intent.setAction(android.content.Intent.ACTION_VIEW);  
    File file = new File("/sdcard/askeroid/logos/1_mobile.png");  
    intent.setDataAndType(Uri.fromFile(file), "image/*");  
    startActivity(intent); 
}  
}
class MyTask extends AsyncTask {
@Override
protected Void doInBackground(Void... params) {
    try{
        URL url = new URL("http://ed.sadko.mobi/logo/logo_1mobile.png");
        URLConnection connection = url.openConnection();
        connection.connect();
        InputStream input = new BufferedInputStream(url.openStream());
        OutputStream output = new FileOutputStream("/sdcard/askeroid/logos/1_mobile.png");
        output.flush();
        output.close();
        input.close();
    } catch(Exception e){e.printStackTrace();}
  return null;
}
}
 
     
     
    