WifiPortalAutoLog is an example project that you can use
As describe in this answer:
Here is an example scenario:
- Device connects to captive Wi-Fi portal
- System displays a captive portal notification
- User touches the notification
- System displays the implicit intent app chooser
- User selects SignInActivity
- MainActivity is launched
In MainActivity You may access the extras mentioned in the ConnectionManager.ACTION_CAPTIVE_PORTAL_SIGN_IN
:
if (ConnectivityManager.ACTION_CAPTIVE_PORTAL_SIGN_IN.equals(intent.getAction())) {
get captivePortal
from bundle to communicate with the system about the outcome of the sign in:
captivePortal = intent.getParcelableExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL);
Use the ConnectivityManager.EXTRA_NETWORK extra (which has type Network) to communicate with the portal (i.e. pass sign in tokens):
net = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK);
Load url in WebView
and also remember set intent filter in manifest:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.net.conn.CAPTIVE_PORTAL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>