我已经从该站点下载了 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 android 代码。
这是下载代码。
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”处遇到错误
最佳答案
伙计,你需要安装 AndFTP 才能使用 FTP(除非你自己实现 FTP 功能)。
让我猜猜您做了什么:您认为通过实现您在 andFtp 网站上找到的代码 fragment ,您将能够在您的应用程序中使用 FTP。
如果我猜对了,那么您并不完全了解 Android 的工作原理以及您必须做什么才能使用 FTP。所以,andFTP 所做的是注册提供一些可以被外部应用程序使用的 Activity ,以便使用 FTP。但是,为了使其正常工作,必须安装 和 FTP 应用程序。
这就是您得到 ActivityNotFound
异常的原因。因此,这是您仅有的两个选择:
- 要么你自己实现所有 FTP 的东西(忘记 andFTP)
- 或者您捕获此类异常并向用户显示一条消息,告诉他们必须安装和 FTP 以便您的应用程序可以正常运行。
关于android - 未发现 Activity 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9893861/