Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need advise for Wifi connection

 
ibrahim yener
Ranch Hand
Posts: 202
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I need advise about connecting Wifi and send/recieve file.

I have couple of activity in my project and let's say activityC is responsible to connect wifi
But how can i send file to PC at activityB and receive file at activityA.

So far, i've made up with this:

1 - create a class for responsible wifi connection
2 - on activityA call this class if connection already established then return wifi object else create new connection
3 - same as #2 for activityB

is this good strategy?

Thanks
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But how can i send file to PC at activityB and receive file at activityA.

TCP/IP has no problems handling multiple simultaneous connections.


1 - create a class for responsible wifi connection
2 - on activityA call this class if connection already established then return wifi object else create new connection
3 - same as #2 for activityB

This sounds a bit odd, frankly, but then I'm not sure what exact problem you're trying to solve. Have you run into any actual problems opening multiple simultaneous connections?
 
ibrahim yener
Ranch Hand
Posts: 202
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ulf
thanks for reply.
So, you are saying connect wifi anywhere of project. How can i send a file or receive a file from different activity?

Using connection ip address in send activity?

No, i am still working on to get wifi connection first.
Why did i ask this question because i want to know how to handle this task.

If you explain me how android phones handle wifi connections?
for example; you just make a wifi connection in Wifi Setup screen in you settings
and then you can send/receive mail, files from very different application. Browse internet ...etc

So, how it works?

Thanks for reply.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The specifics of how you'd transfer a file depend on the protocol you're using. But there are no issues making several simultaneous connections. (Of course, you need to do that in a background thread, not in the event thread, or the OS will come to a halt and your app will likely be terminated by Android after 10 seconds).

As far as the app is concerned, there is no difference between making connections over Wifi or making connections over 3G (or whatever the device has). You should check for connectivity before attempting to connect, though, and you may wish to perform data traffic intensive operations only over Wifi, not 3G.
 
ibrahim yener
Ranch Hand
Posts: 202
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you suggest me a good tutorial site please.
So far i found some tutorials does not match my criteria.

Thanks
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are those criteria? What - specifically - are you unclear about?
 
ibrahim yener
Ranch Hand
Posts: 202
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What i need is that a tutorial about WIFI and Blue Tooth communication and programing.
Something like complete reference.

Please don't recommend me Google developer because that site is useless.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What i need is that a tutorial about WIFI and Blue Tooth communication and programing. Something like complete reference.

A tutorial or a reference? The only complete reference are the javadocs. Note that TCP/IP (which is what you'd use over Wifi) and BlueTooth are two very different beasts - if your app is supposed to use both you will need to code communications twice.

Please don't recommend me Google developer because that site is useless.

It's a pity you think that (and I can't fathom why you would) - that site contains an enormous amount of well-organized and highly useful information. If you can't get information there, and searching for "android bluetooth tutorial" or some such phrase yields nothing, then the only alternative I can think of would be to get a book that covers these topics.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I think about this - why do you think knowing Wifi matters? If you merely want to transfer data, then TCP/IP -most likely HTTP- would be what you'd use.
 
ibrahim yener
Ranch Hand
Posts: 202
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply.
TCP/IP might work but this task must be done via Wifi.
 
Ron McLeod
Bartender
Pie
Posts: 1044
65
Android Eclipse IDE Java Linux MySQL Database Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the ConnectivityManager to check the connection type (TYPE_MOBILE, TYPE_WIFI, TYPE_BLUETOOTH, etc.) before beginning your task. You could also listen for changes in network connectivity (ConnectivityManager.CONNECTIVITY_ACTION) to trigger starting and pausing your task processing if you are expecting connectivity to change.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ibrahim yener wrote:TCP/IP might work but this task must be done via Wifi.

I think you're still not clear on this: they both go together. If you use one, you use the other (unless the device also has a radio module that supports 2G/3G/4G - that would then also be TCP/IP). But there's nothing much to understand about using Wifi on Android; what's there to understand is the TCP/IP protocols you'd be using on top of that, like HTTP.
 
ibrahim yener
Ranch Hand
Posts: 202
Android Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ulf
I think i do understand now.

Once has Wifi connection then everything goes by TCP/IP requests.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic