开发者

android: how to manage 4g if used SDK 2.1 (meaning no WIMAX)

im making an app using SDK 7 (aos 2.开发者_C百科1). But my app refuses to work properly on HTC EVO which is 2.2 due to using 4G connection. My app can't figure out that there is an Internet connection available cause it neither TYPE_MOBILE nor TYPE_WIFI. What to do in such a situation? Should i make 2 versions of app one for 2.1 and another for 2.2?


there is a possibility to manage 4G in API 2.1 (level 7). I did it in following way

    final ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (cm==null)
        return false;

    final NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
    if (activeNetwork==null)
        return false;

    // determine the type of network 
    switch (activeNetwork.getType()){
    case 6:
        isInternetWiMax = true;
        break;
    case ConnectivityManager.TYPE_WIFI:
        isInternetWiFi = true;
        break;
    case ConnectivityManager.TYPE_MOBILE:
        isInternetMobile = true;
        break;
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜