...<br />Intent intent = new Intent();<br />intent.setAction(Intent.ACTION_PICK);<br />// FTP URL (Starts with ftp://, sftp:// or ftps:// followed by hostname and port).<br />Uri ftpUri = Uri.parse("ftp://yourftpserver.com");<br />intent.setDataAndType(ftpUri, "vnd.android.cursor.dir/lysesoft.andftp.uri");<br />// FTP credentials (optional)<br />intent.putExtra("ftp_username", "anonymous");<br />intent.putExtra("ftp_password", "something@somewhere.com");<br />//intent.putExtra("ftp_keyfile", "/sdcard/dsakey.txt");<br />//intent.putExtra("ftp_keypass", "optionalkeypassword");<br />// FTP settings (optional)<br />intent.putExtra("ftp_pasv", "true");<br />//intent.putExtra("ftp_resume", "true");<br />//intent.putExtra("ftp_encoding", "UTF8");<br />// Download<br />intent.putExtra("command_type", "download");<br />// Activity title<br />intent.putExtra("progress_title", "Downloading files ...");<br />// Close activity after transfer (optional)<br />// intent.putExtra("close_ui", "true");<br />// Remote files to download.<br />intent.putExtra("remote_file1", "/remotefolder/subfolder/file1.zip");<br />intent.putExtra("remote_file2", "/remotefolder/subfolder/file2.zip");<br />// Target local folder where files will be downloaded.<br />intent.putExtra("local_folder", "/sdcard/localfolder");<br />startActivityForResult(intent, 0);<br /> ...<br /> ...<br />protected void onActivityResult(int requestCode, int resultCode, Intent data)<br />{<br /> Log.i(TAG, "Result: "+resultCode+ " from request: "+requestCode);<br /> if (data != null)<br /> {<br /> Log.i(TAG, "Status: "+ data.getStringExtra("TRANSFERSTATUS"));<br /> }<br />}<br /> ...
轉:http://www.androidsnippets.org/snippets/187/index.html