Your SlideShare is downloading. ×
0
Android	  Wi-­‐Fi	  and	  Bluetooth	             Jussi	  Pohjolainen	  
WI-­‐FI	  MANAGER	  
WifiManager	  •  WifiManager	  is	  able	     –  List	  current	  configured	  networks	     –  Can	  configure	  the	  curren...
Show	  Wi-­‐Fi	  Informa?on	  
WifiManager’s	  methods	  •  addNetwork(WifiConfigura?on	  wc)	     –  Add	  a	  new	  network	  descrip?on	  to	  the	  set	...
BLUETOOTH	  API	  
Android	  Bluetooth	  API	  •  Wirelessly	  exchange	  data	  with	  other	     bluetooth	  devices	  •  Possibili?es	    ...
Bluetooth	  Permissions	  •  In	  order	  to	  use	  bluetooth	  features,	  one	  must	     declare	  at	  least	  one	  ...
Seng	  Up	  Bluetooth	  
Seng	  Up	  Bluetooth	  
Querying	  Paired	  Devices	  
Discovering	  All	  Devices	  •  To	  discover	  use,	  startDiscovery	  from	     BluetoothAdapter:	      –  mBluetoothAd...
Listening	  to	  Broadcasts	  •  You	  must	  create	  a	  broadcast	  receiver	  that	     listens	  when	  devices	  are...
Broadcast	  Receiver	  // Create a BroadcastReceiver for ACTION_FOUNDprivate final BroadcastReceiver mReceiver = new Broad...
Connec?ng	  •  You	  must	  have	  a	  client	  and	  a	  server	  •  Use	  classes	  BluetoothServerSocket	  and	     Blu...
Server	  
Client	  
Upcoming SlideShare
Loading in...5
×

Android Wi-Fi Manager and Bluetooth Connection

4,489

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,489
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
133
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Android Wi-Fi Manager and Bluetooth Connection"

  1. 1. Android  Wi-­‐Fi  and  Bluetooth   Jussi  Pohjolainen  
  2. 2. WI-­‐FI  MANAGER  
  3. 3. WifiManager  •  WifiManager  is  able   –  List  current  configured  networks   –  Can  configure  the  current  ac?ve  wi-­‐fi  connec?on   –  Results  of  access  point  scans,  •  Needs   android.permission.ACCESS_WIFI_STATE  
  4. 4. Show  Wi-­‐Fi  Informa?on  
  5. 5. WifiManager’s  methods  •  addNetwork(WifiConfigura?on  wc)   –  Add  a  new  network  descrip?on  to  the  set  of   configured  networks.  •  disableNetwork(int  netId)   –  Disable  a  configured  network.    •  List<WifiConfigura?on>  getConfiguredNetworks()   –  Return  a  list  of  all  the  networks  configured  in  the   supplicant.  •  See:  hTp://developer.android.com/reference/ android/net/wifi/WifiManager.html  
  6. 6. BLUETOOTH  API  
  7. 7. Android  Bluetooth  API  •  Wirelessly  exchange  data  with  other   bluetooth  devices  •  Possibili?es   –  Scan  other  devices   –  Connect  to  other  devices  through  discovery   –  Transfer  data   –  Manage  mul?ple  connec?ons    
  8. 8. Bluetooth  Permissions  •  In  order  to  use  bluetooth  features,  one  must   declare  at  least  one  of  the  following:     –  BLUETOOTH   •  Reques?ng,  accep?ng,  and  transferring  data   –  BLUETOOTH_ADMIN   •  Device  discovery  and  manipulate  bluetooth  sengs  
  9. 9. Seng  Up  Bluetooth  
  10. 10. Seng  Up  Bluetooth  
  11. 11. Querying  Paired  Devices  
  12. 12. Discovering  All  Devices  •  To  discover  use,  startDiscovery  from   BluetoothAdapter:   –  mBluetoothAdapter.startDiscovery();•  Will  return  boolean  value  if  the  discovering   started  ok.  •  Discovery  is  asynchronous  and  last  about  12   secs  •  When  devices  are  discovered  broadcast   happens…  
  13. 13. Listening  to  Broadcasts  •  You  must  create  a  broadcast  receiver  that   listens  when  devices  are  discovered  •  Register   –  IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); –  registerReceiver(mReceiver, filter); –  // Dont forget to unregister during onDestroy  
  14. 14. Broadcast  Receiver  // Create a BroadcastReceiver for ACTION_FOUNDprivate final BroadcastReceiver mReceiver = new BroadcastReceiver() {    public void onReceive(Context context, Intent intent) {        String action = intent.getAction();        // When discovery finds a device        if (BluetoothDevice.ACTION_FOUND.equals(action)) {            // Get the BluetoothDevice object from the Intent            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);            // Add the name and address to an array adapter to show in a ListView            mArrayAdapter.add(device.getName() + "n" + device.getAddress());        }    }};
  15. 15. Connec?ng  •  You  must  have  a  client  and  a  server  •  Use  classes  BluetoothServerSocket  and   BluetoothSocket•  Connec?on  is  done  in  separate  thread  •  You  have  to  have  server  and  client  
  16. 16. Server  
  17. 17. Client  
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×