2

I have a WiFi access point that people may connect to. When they do, I need to automatically open a website. Is this possible?

halfer
  • 19,824
  • 17
  • 99
  • 186
Anand agrawal
  • 492
  • 6
  • 25
  • 1
    If you had an app running on the device to do that, then yes. But if you want adverts to pop up on someone's phone just because they walked in range of a wifi device, then the answer is (thankfully) no. There was a thought some years ago that BlueTooth was going to help advertisers do near-location based stuff, but that doesn't seem to have materialised, especially since it is worth turning BlueTooth off unless you are using it. – halfer May 01 '15 at 09:14
  • No I just want to through page when they want to connect with my network. – Anand agrawal May 01 '15 at 09:16
  • Yes, that's possible. They do this in cafes where free public wifi is offered. I imagine you'd need to set up some proxy software to examine the traffic going through it. Where a new MAC address is seen (or hasn't been seen for a few days) then you inject a redirect into the HTTP stream (doesn't work on SSL of course, which cannot be tampered with). Sometimes this is used to pop up a page to ask someone to sign an acceptable usage policy. I imagine there is software available to do this. – halfer May 01 '15 at 09:21
  • Some approaches here: https://en.wikipedia.org/wiki/Captive_portal – halfer May 01 '15 at 09:25

1 Answers1

0

you can do it using android service which is running in background and in background you need to check every time that you are connected on a network or not if you are connected then open a browser intent with your web address

in service you need to create a broadcast receiver and in on receive you need to check following :

 @Override
  public void onReceive(Context context, Intent intent) {

   String action = intent.getAction();

    if(WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action)){

     Log.d("WIFI", "WIFI has changed");
     int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, -1);
     Log.d("WIFI", "WIFI State = " + wifiState);
     setCurrentWifiState(wifiState);

     }  
Milap Pancholi
  • 134
  • 1
  • 12