2017-12-11 2 views
0

저는 Android Studio에 처음 입문했으며이 질문은 전문가에게는 어리석은 것 같지만 ....txt 파일을 FTP 서버에 업로드 하시겠습니까?

스마트 폰 (Samsung Galaxy S7, API23)에서 .txt 파일을 업로드하고 싶습니다. FTP 서버. 이것은 내가 지금까지 가지고있는 것입니다 :

import org.jibble.simpleftp.SimpleFTP; 

public class MainActivity extends AppCompatActivity implements View.OnClickListener{ 

    Button btnAusfuehren; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     btnAusfuehren=(Button) findViewById(R.id.btnAusfuehren); 
     btnAusfuehren.setOnClickListener(this); 
    } 

    @Override 
    public void onClick(View view) { 

     try 
     { 
      SimpleFTP ftp = new SimpleFTP(); 

      // Connect to an FTP server on port 21. 
      ftp.connect("1bk2t.ddns.net", 21, "User", "Password"); 

      // Set binary mode. 
      //ftp.bin(); 

      // Change to a new working directory on the FTP server. 
      //ftp.cwd("Rollladen"); 

      // Upload some files. 
      //ftp.stor(new File("befehl.txt")); 


      // Quit from the FTP server. 
      ftp.disconnect(); 
     } 
     catch (IOException e) 
     { 
      e.printStackTrace(); 
     } 
    } 
} 

내 스마트 폰에 프로그램을 디버깅하고 버튼을 누를 때마다 앱이 작동을 멈 춥니 다. 내가 뭘 잘못 했니?

+1

스택 추적을 게시해야합니다. –

답변

0

Google for NetworkOnMainThreadException.

당신의 logcat은 당신이 가지고 있다고 말해 줄 것입니다.

관련 문제