This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Android and the fly likes Ftp doesnt work on phone but works on emulator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Ftp doesnt work on phone but works on emulator" Watch "Ftp doesnt work on phone but works on emulator" New topic
Author

Ftp doesnt work on phone but works on emulator

David Lakatos
Greenhorn

Joined: Aug 28, 2012
Posts: 8
i wrote this ftp upload method...it works great on the emulator but doesnt on my phone...

can someone tell me why not?









i wrote this ftp upload method...it works great on the emulator but doesnt on my telephone...my phone feeze when it runs. I cant have log from the phone sorry that's why i ask to try it please!

can someone tell me why not?

please help i'm trying to do this ftp almost 3 days:S
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

When you say "doesn't work", what does that mean? Read our FAQ entry ItDoesntWorkIsUseless, which should tell you what kind of information would be useful to somebody who wanted to help you out.

(And in particular, does this line of code run:



and what does it output?)
David Lakatos
Greenhorn

Joined: Aug 28, 2012
Posts: 8
Paul Clapham wrote:When you say "doesn't work", what does that mean? Read our FAQ entry ItDoesntWorkIsUseless, which should tell you what kind of information would be useful to somebody who wanted to help you out.

(And in particular, does this line of code run:



and what does it output?)


update my post...please try it on phonecause i cant have log from phone
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41634
    
  55
David Lakatos wrote:please try it on phonecause i cant have log from phone

Why not? That's what "adb logcat" is for if you connect your phone via USB to your computer.

But more importantly, I don't think you can construct a FileInputStream that way in Android. You need to obtain it from other API methods. See "Internal Storage" and "External Storage" in http://developer.android.com/guide/topics/data/data-storage.html


Ping & DNS - my free Android networking tools app
David Lakatos
Greenhorn

Joined: Aug 28, 2012
Posts: 8

Ulf Dittmer wrote:Why not? That's what "adb logcat" is for if you connect your phone via USB to your computer.

because i cant connect the phone to eclipse.
Thats why i ask for test it to me and give me a log :) please
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41634
    
  55
Your code is incomplete - it would take anyone of us a long time to make an app out of it to install on the phone. Nobody is going to do that. But I already told you what to look for.

Also, I'm certain that Eclipse can connect to your phone. And even if it can't for some reason, the command line version of adb can, so you can proceed on your own.
David Lakatos
Greenhorn

Joined: Aug 28, 2012
Posts: 8
Ulf Dittmer wrote:Your code is incomplete - it would take anyone of us a long time to make an app out of it to install on the phone. Nobody is going to do that. But I already told you what to look for.

Also, I'm certain that Eclipse can connect to your phone. And even if it can't for some reason, the command line version of adb can, so you can proceed on your own.


got the error log: android.os.NetworkOnMainThreadException

any idea?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41634
    
  55
On Android, any network activity must be done in a background thread, not the main event handling thread. The reason being that network activity generally takes longer than you can afford to block the main thread. Search for "AsyncTask" for a solution.
 
Consider Paul's rocket mass heater.
 
subject: Ftp doesnt work on phone but works on emulator