2012-03-27 77 views
1

我已經下載從這個站點的示例代碼中的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", "[email protected]"); 
       //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

您是否安裝了AndFTP應用程序? – Cristian 2012-03-27 16:42:00

+0

不,那需要什麼 – user1293519 2012-03-27 16:56:02

回答

3

男人,你需要安裝AndFTP才能夠使用FTP(除非你自己實現FTP功能)。

讓我猜你做了什麼:你認爲通過實現你在andFtp網站中找到的代碼片段,你將能夠在你的應用程序中使用FTP。

如果我猜對了,那麼你完全不瞭解Android的工作原理以及爲了使用FTP你必須做什麼。所以,FTP所做的是註冊提供一些可供外部應用程序使用的活動,以便使用FTP。但是,爲了使其工作,必須安裝和FTP應用程序

這就是爲什麼你會得到ActivityNotFound異常。因此,這裏有你只有兩種選擇:

  • 要麼你通過你的自我實現所有的FTP的東西(而忘記了andFTP)
  • 或者你趕上那種異常,並顯示告訴他們一個消息給用戶他們必須安裝和FTP,以便您的應用程序可以正常運行。
0

你檢查活動在Android清單中列出?這會導致這種錯誤。

+0

是的,我只有一個活動,它在清單中列出。 – user1293519 2012-03-27 16:54:08

+0

您是否將此意圖過濾器添加到了您的mainactivity? <意圖濾波器> <操作機器人:名稱= 「android.intent.action.PICK」/> <類別機器人:名稱= 「android.intent.category.DEFAULT」/> <數據機器人:mime類型=「vnd.android.cursor.dir/lysesoft.andftp.uri」/> cuneytyvz 2012-03-27 17:15:32

+0

是的,我添加了它,但仍然崩潰。 – user1293519 2012-03-27 17:38:41

0

首先您必須在AndroidManifest.xml文件中定義您的活動。 如果您使用的是Android應用程序中的任何活動,則必須在AndroidManifest.xml文件中進行定義。

+0

我只有一個活動,我已經在清單文件中聲明它。 – user1293519 2012-03-27 17:39:39

相關問題