2

I am a fellow Android developer and want to develop a similar app like Firechat for educational purposes

I just want to know what kind of packages and techniques I need to learn to develop a app like this

App Features : I Need to discover the phones which Have wifi direct and my App on Next I need to be able to send messages and start device to device communication and If the device I want to connect is not in range ,The message should Hop from one device to another till the destination is reached I think It can done by creating a mesh network

I have went through similar techonlogies like serval/Firechat/Opengarden ,But I am not being able to comprehend it

abhirulz
  • 87
  • 1
  • 2
  • 11

1 Answers1

7

For being able to connect devices for peer to peer connection you have the following options:

1. Wifi Direct

2. Bluetooth

3. Wifi Hotspot

Here is a basic tutorial on how to build a chat over wifi direct http://developer.android.com/guide/topics/connectivity/wifip2p.html

And for bluetooth http://developer.android.com/samples/BluetoothChat/index.html

You can also import these sample projects in eclipse by:

1 For WifiDirect -
Go to New -> Android Sample Project -> Choose API level 16 (Android 4.1.2)-> WifiDirectDemo

2 For Bluetooth -
Go to New -> Android Sample Project -> Choose API level 16 (Android 4.1.2)> BluetoothChat

Community
  • 1
  • 1
Sahil Bahl
  • 679
  • 3
  • 11
  • Is the wifi-direct same as wifi ? I mean if a person B just turns on his wifi ,Could Person A detect his phone ? – abhirulz May 29 '15 at 14:28
  • Wifi Direct is not same as wifi . On Jelly Bean and above, when you try to use the WifiP2pManager API, WiFi-Direct is automatically enabled (as long as WiFi is on). Wifi can be switched on by calling WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); wifiManager.setWifiEnabled(true); For ICS refer to this http://stackoverflow.com/questions/8571566/can-i-turn-on-wifi-direct-from-code-on-android-api-14-ics – Sahil Bahl May 30 '15 at 04:43
  • After wifi Direct is on , for A to see B and vice versa both devices should be discoverable . To be discoverable both devices should call WifiP2pManager manager = (WifiP2pManager) context.getSystemService(Context.WIFI_P2P_SERVICE); And Then Call manager.discoverPeers(channel, listener) This makes both devices discoverable and see each other . Mark my answer as correct if satisfied – Sahil Bahl May 30 '15 at 04:48
  • If one device name B minimizes the app, after calling WIFI_P2P_SERVICE , Will it still be discover-able by other devices like A who has the app running .? and Can I know how to transfer strings from both Client to Server and server to client once the connection is set up ? – abhirulz May 30 '15 at 16:25
  • In any situation if discovery ends you get a system broadcast WifiP2pManager.WIFI_P2P_DISCOVERY_CHANGED_ACTION(You need to register for this intent) You can get the state of discovery as intent.getIntExtra(WifiP2pManager.EXTRA_DISCOVERY_STATE) IF discovery has stopped you can call l manager.discoverPeers(channel, listener) to make discovery active again . – Sahil Bahl May 31 '15 at 05:39
  • For a 2 directional transfer try this https://github.com/ahmontero/wifi-direct-demo Please upvote my comments and answer . Thanks – Sahil Bahl May 31 '15 at 05:44