Ftp下载图片并显示
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); this.pd = ProgressDialog.show(this, "Working...", "*** Downloading Data...", true, false); new DownloadTask().execute(" parameters needed for download"); } private class DownloadTask extends AsyncTask<String, Void, Object> { protected Void doInBackground(String... args) { Log.d("********Jorgesys", "Background thread starting......"); startLongRunningOperation(); return null; } protected void onPostExecute(Object result) { Log.d("********Jorgesys", "onPostExecute......"); if (Splash.this.pd != null) { Splash.this.pd.dismiss(); } updateResultsInUi(); } } protected void startLongRunningOperation() { try { ftp = new FTPClient(); ftp.connect(host); ftp.login("username", "password"); ftp.changeDirectory("public_ftp"); ftp.download("test.jpg", new java.io.File("/sdcard/test.jpg")); } catch(Exception e) { } }
?