vendredi 13 mars 2020

How to check if reflection worked or not?

i am using below method to check if Hotspot AP was enabled or not but there is a warning that says:

private boolean isApOn() {
    try {
        Method method = wifiManager.getClass().getDeclaredMethod("isWifiApEnabled"); // warning is here
        method.setAccessible(true);
        return (boolean)method.invoke(wifiManager);
    } catch (Throwable ignored) {
    }
    return false;
}

Accessing internal APIs via reflection is not supported and may not work on all devices or in the future

so there is my question that How can i check it if it worked or not?





Aucun commentaire:

Enregistrer un commentaire