我已从此网站下载了FTP客户端http://www.lysesoft.com/products/andftp/index.html
的示例代码但是当我运行该项目时,我遇到了这个异常并崩溃了。
03-27 21:40:44.572: INFO/System.out(559): EEE : No Activity found to handle Intent { act=android.intent.action.PICK dat=ftp://192.168.20.128 typ=vnd.android.cursor.dir/lysesoft.andftp.uri (has extras) }
这是什么原因? 任何人都可以为我提供一个完整的FTP代码。
这是下载的代码。
Intent intent = new Intent();
intent.setAction(Intent.ACTION_PICK);
// FTP URL (Starts with ftp://, sftp://, ftps:// or scp:// followed by hostname and port).
Uri ftpUri = Uri.parse("ftp://192.168.20.128");
intent.setDataAndType(ftpUri, "vnd.android.cursor.dir/lysesoft.andftp.uri");
// Download
intent.putExtra("command_type", "download");
// FTP credentials (optional)
intent.putExtra("ftp_username", "anonymous");
intent.putExtra("ftp_password", "test@test.com");
//intent.putExtra("ftp_keyfile", "/sdcard/dsakey.txt");
//intent.putExtra("ftp_keypass", "optionalkeypassword");
// FTP settings (optional)
intent.putExtra("ftp_pasv", "true");
//intent.putExtra("ftp_resume", "true");
//intent.putExtra("ftp_encoding", "UTF-8");
//intent.putExtra("ftps_mode", "implicit");
// Activity title
intent.putExtra("progress_title", "Downloading files ...");
// Remote files to download.
intent.putExtra("remote_file1", "/remotefolder/subfolder/file1.zip");
intent.putExtra("remote_file2", "/remotefolder/subfolder/file2.zip");
// Target local folder where files will be downloaded.
intent.putExtra("local_folder", "/sdcard/localfolder");
intent.putExtra("close_ui", "true");
startActivityForResult(intent, DOWNLOAD_FILES_REQUEST);
我在“startActivityForResult”中收到错误
答案 0 :(得分:3)
伙计,你需要安装AndFTP才能使用FTP(除非你自己实现FTP功能)。
让我猜猜你做了什么:你认为通过实现你在andFtp网站上找到的代码片段,你将能够在你的应用程序中使用FTP。
如果我猜对了,那么你就完全不了解Android的工作方式以及为了使用FTP而必须做的事情。那么,andFTP做的是注册提供一些可以被外部应用程序用来使用FTP的活动。但是,为了使其正常工作,必须安装 。。
这就是你得到ActivityNotFound
例外的原因。所以这是你唯一的两个选择:
答案 1 :(得分:0)
您是否检查过Android清单中列出的活动?这会导致这种错误。
答案 2 :(得分:0)
首先,您必须在AndroidManifest.xml文件中定义您的活动。 如果您正在使用在Android应用程序中运行的任何活动,则必须在AndroidManifest.xml文件中定义。