Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Captive Portal inside Android App

Can anyone suggest how to open captive portal inside android app?

i have gone through below links https://developer.android.com/reference/android/net/CaptivePortal.html Using ACTION_CAPTIVE_PORTAL_SIGN_IN

Can anyone have a complete guide to use captive portal inside android application?

like image 709
Pratik Avatar asked Jul 25 '17 12:07

Pratik


People also ask

What is captive portal on my Android?

The captive portal feature is a software implementation that blocks clients from accessing the network until user verification has been established. You can set up verification to allow access for both guests and authenticated users.

Why is captive portal on my phone?

Captive portal login is what public Wi-Fi routers use to grant access. When you connect to a public Wi-Fi and it redirects you to a screen asking you to agree to the terms of use, that is the captive portal login in action. Welcome to Android Central!


2 Answers

Following is flow of pushing captive portals

enter image description here

Use following android doc for programming part

https://developer.android.com/reference/android/net/CaptivePortal.html

Think this will useful

like image 139
Nisal Edu Avatar answered Sep 30 '22 05:09

Nisal Edu


WifiPortalAutoLog is an example project that you can use

As describe in this answer: Here is an example scenario:

  1. Device connects to captive Wi-Fi portal
  2. System displays a captive portal notification
  3. User touches the notification
  4. System displays the implicit intent app chooser
  5. User selects SignInActivity
  6. 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>
like image 23
Hamed Ghadirian Avatar answered Sep 30 '22 05:09

Hamed Ghadirian