Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.annotation.SuppressLint;

import android.content.Context;

import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main {

    @SuppressLint("DefaultLocale")
    public static boolean isCMWap(Context context) {
        boolean res = false;
        ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

        if (networkInfo == null) {
            return res;
        }
        int nType = networkInfo.getType();
        String eInfo = networkInfo.getExtraInfo();
        if (nType == ConnectivityManager.TYPE_MOBILE && eInfo != null) {
            if (eInfo.toLowerCase().equals("cmwap")) {
                res = true;
            }
        }

        return res;
    }
}