Get started
Introduction
Installation
Your first app
Tutorials
Fission tutorials
Scan for Wi-Fi networks on Android with Fission
Core concepts
Components
State and effects
Protected routes
Server-side rendering
Styling
Testing
Deployment
Reference
API reference
Cookbook
Fission 0.16.0
Documentation version
Read the changelog →

Scan for Wi-Fi networks on Android with Fission

Check Wi-Fi access and read matching network results for an upload workflow. Treat cached results as observations, not proof of connectivity.
Android

What you will build

Look for the user-supplied site network prefix after checking permission, without claiming a fresh exhaustive scan or joining the network.
Keep the expected network prefix separate from provider results
Request permission and explicitly recheck after Android's prompt
Read matching Wi-Fi results with registered success and failure callbacks
Recognise cached scan results and leave connection changes to Android Settings

Discovery is not a connection

An inspection report may be ready to upload whilst the phone is still offline. The useful question at that point is whether the expected site network appears in Android's results, not whether the application can manufacture an upload confirmation.
This screen takes the expected prefix from the user, checks Wi-Fi and permission, then requests matching network results. It never asks for a password. The Android provider does not implement connecting or disconnecting; use Android Settings for those operations. A matching name does not authenticate an access point, and a successful scan does not establish internet access.

Create the shared app

Complete SDK/NDK setup, then prepare an emulator or a phone.
cargo install cargo-fission
fission init android-use-fissions-android-wi-fi-capability
cd android-use-fissions-android-wi-fi-capability
fission add-target android --project-dir .
fission add-capability wifi --project-dir .
cargo add serde_yaml
Keep the generated src/main.rs. Shared state owns confirmed provider results; the component owns the editable prefix. The same library runs natively and in Web, using the real target provider rather than a memory host.

Run the finished example

fission run --target android --project-dir .

1. Ask, recheck, then scan

Permission requests and permission results are different events. The current Android provider returns a permission snapshot immediately after requesting the OS dialog; it does not wait for the user's answer. Consequently, the screen asks the user to finish that dialog and explicitly check again. It does not chain a scan onto an assumed grant.
There is a second boundary worth making explicit. The provider calls startScan and immediately reads getScanResults; it does not wait for a fresh scan broadcast, check whether that request was accepted, or enforce timeout_ms. Results can therefore be cached or empty. Present the returned count as precisely that, not as proof that nearby networks were exhaustively searched.
{"id":"fission-tabs-1","tabs":[{"index":0,"label":"src/state.rs","value":"src-state-rs"},{"index":1,"label":"src/app.rs","value":"src-app-rs"},{"index":2,"label":"src/translations.rs","value":"src-translations-rs"},{"index":3,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"},{"index":4,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"},{"index":5,"label":"src/lib.rs","value":"src-lib-rs"},{"index":6,"label":"preview/lib.rs","value":"preview-lib-rs"}]}
{"id":"fission-tabs-1","index":0,"label":"src/state.rs","value":"src-state-rs"}
use fission::prelude::*;

#[derive(Debug, Default)]
pub struct NetworkCheck {
    pub availability: Option<WifiAvailability>,
    pub networks: Option<Vec<WifiNetwork>>,
    pub scan_prefix: Option<String>,
    pub pending: bool,
    pub issue: Option<&'static str>,
}
impl GlobalState for NetworkCheck {}

impl NetworkCheck {
    pub fn can_scan(&self) -> bool {
        !self.pending && self.availability.as_ref().is_some_and(|value| {
            value.enabled && value.permission == WifiPermission::Granted
        })
    }
}

pub fn check_wifi(state: &mut NetworkCheck, ctx: &mut ReducerContext<NetworkCheck>) {
    if state.pending { return; }
    state.pending = true;
    state.issue = None;
    let ok = ctx.effects.bind(WifiChecked, reduce_with!(wifi_checked));
    let err = ctx.effects.bind(WifiCheckFailed, reduce_with!(wifi_check_failed));
    ctx.effects.wifi().availability().on_ok(ok).on_err(err);
}

#[fission_reducer(WifiChecked)]
pub fn wifi_checked(state: &mut NetworkCheck, ctx: &mut ReducerContext<NetworkCheck>) {
    state.pending = false;
    match ctx.input.capability_ok(GET_WIFI_AVAILABILITY) {
        Some(value) => state.availability = Some(value),
        None => state.issue = Some("wifi.missing"),
    }
}
#[fission_reducer(WifiCheckFailed)]
pub fn wifi_check_failed(state: &mut NetworkCheck, ctx: &mut ReducerContext<NetworkCheck>) {
    state.pending = false;
    state.issue = Some(match ctx.input.capability_error(GET_WIFI_AVAILABILITY) {
        Some(error) if error.code == "unsupported" => "wifi.unsupported",
        _ => "wifi.failed",
    });
}

#[fission_reducer(RequestWifiAccess)]
pub fn request_wifi_access(
    state: &mut NetworkCheck, reason: String, ctx: &mut ReducerContext<NetworkCheck>,
) {
    if state.pending { return; }
    state.pending = true;
    state.issue = None;
    let ok = ctx.effects.bind(WifiAccessReceived, reduce_with!(wifi_access_received));
    let err = ctx.effects.bind(WifiAccessFailed, reduce_with!(wifi_access_failed));
    ctx.effects.wifi().request_permission(WifiPermissionRequest { reason: Some(reason) })
        .on_ok(ok).on_err(err);
}
#[fission_reducer(WifiAccessReceived)]
pub fn wifi_access_received(state: &mut NetworkCheck, ctx: &mut ReducerContext<NetworkCheck>) {
    state.pending = false;
    if ctx.input.capability_ok(REQUEST_WIFI_PERMISSION).is_none() {
        state.issue = Some("wifi.missing");
    } else {
        // Android may still be displaying its prompt. Do not treat this snapshot
        // as the user's eventual answer; Check Wi-Fi reads permission again.
        state.availability = None;
        state.issue = Some("wifi.recheck");
    }
}
#[fission_reducer(WifiAccessFailed)]
pub fn wifi_access_failed(state: &mut NetworkCheck, ctx: &mut ReducerContext<NetworkCheck>) {
    state.pending = false;
    state.issue = Some(match ctx.input.capability_error(REQUEST_WIFI_PERMISSION) {
        Some(error) if error.code == "unsupported" => "wifi.unsupported",
        _ => "wifi.failed",
    });
}

pub fn scan_wifi(state: &mut NetworkCheck, prefix: String, ctx: &mut ReducerContext<NetworkCheck>) {
    if !state.can_scan() || prefix.trim().is_empty() { return; }
    state.pending = true;
    state.issue = None;
    state.networks = None;
    let prefix = prefix.trim().to_owned();
    state.scan_prefix = Some(prefix.clone());
    let ok = ctx.effects.bind(WifiScanned, reduce_with!(wifi_scanned));
    let err = ctx.effects.bind(WifiScanFailed, reduce_with!(wifi_scan_failed));
    ctx.effects.wifi().scan_networks(WifiScanRequest {
        ssid_prefix: Some(prefix),
        include_hidden: false,
        timeout_ms: Some(5_000),
    }).on_ok(ok).on_err(err);
}
#[fission_reducer(WifiScanned)]
pub fn wifi_scanned(state: &mut NetworkCheck, ctx: &mut ReducerContext<NetworkCheck>) {
    state.pending = false;
    match ctx.input.capability_ok(SCAN_WIFI_NETWORKS) {
        Some(value) => state.networks = Some(value.networks),
        None => state.issue = Some("wifi.missing"),
    }
}
#[fission_reducer(WifiScanFailed)]
pub fn wifi_scan_failed(state: &mut NetworkCheck, ctx: &mut ReducerContext<NetworkCheck>) {
    state.pending = false;
    state.issue = Some(match ctx.input.capability_error(SCAN_WIFI_NETWORKS) {
        Some(error) if error.code == "unsupported" => "wifi.unsupported",
        Some(error) if error.code == "permission_denied" => {
            state.availability = None;
            "wifi.denied"
        }
        _ => "wifi.failed",
    });
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn scanning_requires_enabled_wifi_and_a_confirmed_permission() {
        let mut state = NetworkCheck::default();
        assert!(!state.can_scan());
        state.availability = Some(WifiAvailability {
            enabled: true, permission: WifiPermission::Denied, connected_network: None,
        });
        assert!(!state.can_scan());
        state.availability.as_mut().unwrap().permission = WifiPermission::Granted;
        assert!(state.can_scan());
        state.pending = true;
        assert!(!state.can_scan());
    }
}
{"id":"fission-tabs-1","index":1,"label":"src/app.rs","value":"src-app-rs"}
use fission::prelude::*;
use crate::state::*;

fission_component! {
    pub UploadNetworkScreen<NetworkCheck> {
        state { network_prefix: String = String::new() }
    }
    view(screen, state, cx) {
        let tokens = &cx.view.env().theme.tokens;
        let request = with_reducer!(
            cx.build, RequestWifiAccess(cx.tr("wifi.reason")), request_wifi_access
        );
    } =>
    SafeArea(child: Scroll(child: Container(
        Column(gap: tokens.spacing.m, children: [
            Text(cx.tr("wifi.title")).size(tokens.typography.heading2_size),
            Text(cx.tr("wifi.context")),
            TextInput(
                label: Some(cx.tr("wifi.prefix").into()),
                helper_text: Some(cx.tr("wifi.prefix_help").into()),
                bind: screen.network_prefix,
                read_only: state.pending,
                semantics_identifier: "wifi.prefix".to_owned(),
            ),
            Button(
                child: Text(cx.tr("wifi.check")),
                key: "wifi.check", disabled: state.pending,
                on_press: reduce { check_wifi(state, cx); },
            ),
            Button(
                child: Text(cx.tr("wifi.request")),
                key: "wifi.request", disabled: state.pending,
                on_press: request,
            ),
            if let Some(value) = &state.availability {
                Column(gap: tokens.spacing.s, children: [
                    Text(cx.tr(if value.enabled { "wifi.enabled" } else { "wifi.disabled" })),
                    Text(cx.tr(if value.permission == WifiPermission::Granted {
                        "wifi.granted"
                    } else { "wifi.not_granted" })),
                ])
            },
            Button(
                child: Text(cx.tr("wifi.scan")),
                key: "wifi.scan",
                disabled: !state.can_scan() || screen.network_prefix.trim().is_empty(),
                on_press: reduce { scan_wifi(state, screen.network_prefix.clone(), cx); },
            ),
            if state.pending {
                Spinner(motion: Some(SpinnerMotion::Default), label: cx.tr("wifi.pending"))
            },
            if let Some(issue) = state.issue {
                Text(cx.tr(issue)).color(tokens.colors.text_secondary)
            },
            if let Some(networks) = &state.networks {
                Column(gap: tokens.spacing.s, children: [
                    if let Some(prefix) = &state.scan_prefix {
                        Text(format!("{}: {}", cx.tr("wifi.results_for"), prefix))
                    },
                    Text(format!("{} {}", cx.tr("wifi.returned"), networks.len())),
                    Text(cx.tr("wifi.cached")),
                ])
            },
            Text(cx.tr("wifi.boundary")),
        ])
    ).padding_all(tokens.spacing.l)))
}
{"id":"fission-tabs-1","index":2,"label":"src/translations.rs","value":"src-translations-rs"}
use std::collections::HashMap;
use fission::prelude::*;

pub fn create_env() -> Env {
    let mut env = Env::default();
    env.locale = Locale::from("en-US");
    for (locale, source) in [
        ("en-US", include_str!("../i18n/en-US.yaml")),
        ("es-ES", include_str!("../i18n/es-ES.yaml")),
    ] {
        let messages: HashMap<String, String> =
            serde_yaml::from_str(source).expect("valid checked-in translations");
        env.i18n.add_bundle(TranslationBundle { locale: Locale::from(locale), messages });
    }
    env
}
{"id":"fission-tabs-1","index":3,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"}
wifi.title: "Check the upload network"
wifi.context: "Enter the network prefix supplied by your site administrator. Scanning does not upload a report or connect this phone."
wifi.prefix: "Expected network prefix"
wifi.prefix_help: "Network names are not proof of identity. Do not enter a Wi-Fi password."
wifi.check: "Check Wi-Fi and permission"
wifi.request: "Request access"
wifi.reason: "Look for the site's upload network."
wifi.scan: "Read matching network results"
wifi.enabled: "Wi-Fi is enabled."
wifi.disabled: "Enable Wi-Fi in Android Settings, then check again."
wifi.granted: "The provider currently reports permission granted."
wifi.not_granted: "Access is not granted. The report can still be prepared without scanning."
wifi.pending: "Waiting for the Wi-Fi provider…"
wifi.returned: "Matching results returned:"
wifi.results_for: "Results returned for prefix"
wifi.cached: "Android may return cached results; this is not proof the network is reachable now."
wifi.boundary: "Connect through Android Settings. This app does not join networks, transmit data or verify internet access."
wifi.recheck: "Finish the Android prompt, then choose Check Wi-Fi and permission."
wifi.denied: "Access is no longer available. Check permission again; the expected network name is unchanged."
wifi.unsupported: "This host does not support Wi-Fi discovery. The browser preview does not invent nearby networks."
wifi.failed: "The provider could not complete this operation. Check Android settings before retrying."
wifi.missing: "The provider did not return the expected result."
{"id":"fission-tabs-1","index":4,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}
wifi.title: "Comprobar la red de carga"
wifi.context: "Introduce el prefijo de red facilitado por el administrador. Buscar redes no carga un informe ni conecta este teléfono."
wifi.prefix: "Prefijo de red esperado"
wifi.prefix_help: "El nombre no demuestra la identidad de una red. No introduzcas contraseñas."
wifi.check: "Comprobar Wi-Fi y permiso"
wifi.request: "Solicitar acceso"
wifi.reason: "Buscar la red de carga del centro."
wifi.scan: "Leer resultados de redes coincidentes"
wifi.enabled: "Wi-Fi está activado."
wifi.disabled: "Activa Wi-Fi en Ajustes de Android y vuelve a comprobar."
wifi.granted: "El proveedor indica que el permiso está concedido."
wifi.not_granted: "No hay permiso. Puedes preparar el informe sin buscar redes."
wifi.pending: "Esperando al proveedor Wi-Fi…"
wifi.returned: "Resultados coincidentes recibidos:"
wifi.results_for: "Resultados para el prefijo"
wifi.cached: "Android puede devolver resultados anteriores; no demuestra que la red sea accesible ahora."
wifi.boundary: "Conecta mediante Ajustes de Android. Esta aplicación no se conecta a redes, transmite datos ni comprueba internet."
wifi.recheck: "Termina el diálogo de Android y pulsa Comprobar Wi-Fi y permiso."
wifi.denied: "El acceso ya no está disponible. Comprueba el permiso; el nombre esperado no cambia."
wifi.unsupported: "Este entorno no admite buscar redes Wi-Fi. La vista del navegador no inventa redes cercanas."
wifi.failed: "El proveedor no completó la operación. Comprueba Ajustes antes de repetir."
wifi.missing: "El proveedor no devolvió el resultado esperado."
{"id":"fission-tabs-1","index":5,"label":"src/lib.rs","value":"src-lib-rs"}
pub mod app;
pub mod state;
mod translations;

use app::UploadNetworkScreen;
use state::NetworkCheck;
use fission::prelude::*;

#[cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))]
pub fn run_desktop() -> anyhow::Result<()> {
    DesktopApp::<NetworkCheck, _>::new(UploadNetworkScreen)
        .with_env(translations::create_env())
        .run()
}
#[cfg(any(target_os = "android", target_os = "ios"))]
fn mobile_app() -> MobileApp<NetworkCheck, UploadNetworkScreen> {
    let app = MobileApp::<NetworkCheck, _>::new(UploadNetworkScreen)
        .with_env(translations::create_env());
    #[cfg(all(target_os = "android", debug_assertions))]
    let app = app.with_test_control_port(48761);
    app
}
#[cfg(any(target_os = "android", target_os = "ios"))]
pub fn run_mobile() -> anyhow::Result<()> { mobile_app().run() }

#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app_handle: AndroidApp) {
    let _ = mobile_app().run_with_android_app(app_handle);
}
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen::prelude::wasm_bindgen(start)]
pub fn run_web() -> Result<(), wasm_bindgen::JsValue> {
    console_error_panic_hook::set_once();
    WebApp::<NetworkCheck, _>::new(UploadNetworkScreen)
        .with_env(translations::create_env())
        .run()
        .map_err(|error| wasm_bindgen::JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":6,"label":"preview/lib.rs","value":"preview-lib-rs"}
include!("../src/lib.rs");
{"id":"fission-tabs-1"}
The prefix is user input, the returned count is provider data, and neither changes the phone's connection. Whilst a request is pending, another request cannot replace its result. A denied or unsupported response leaves the prefix intact.
Show the app preview
Hide the app preview

2. Check the Android conditions separately

cargo test
fission doctor android --project-dir .
adb devices -l
fission run --target android --device <adb-serial> --project-dir .
fission test --target android --project-dir .
fission build --target android --project-dir . --release
On a phone, check with Wi-Fi disabled, with access denied, and after changing permission in Settings. Complete the permission prompt before rechecking. Compare the expected prefix with Android Settings and repeat after waiting; Android can throttle scans, and cached results need not change immediately. An empty result must not erase the editable prefix or claim that no network exists.
The provider's permission predicate accepts nearby-device or location grants depending on Android version. That check is not a guarantee that every OS scanning prerequisite is satisfied: location settings and platform restrictions can still reject the operation. Keep the explicit failure path. Do not collect or log SSIDs and BSSIDs merely to debug the interface.
The Web preview exercises the form and its actual unsupported result; it cannot demonstrate native Wi-Fi discovery. Unit tests establish the app's gating rule, not Android's permission behaviour. Build, install, scan freshness and real-device behaviour require their own evidence.

Current references

A completed Android check records the device/API, permission choice, adapter state and returned outcome. It does not require sharing the network names. Connecting and uploading remain outside this example.