【问题标题】:how to get current device Data Activity Android如何获取当前设备数据活动 Android
【发布时间】:2017-01-02 18:54:58
【问题描述】:

在我的 Android 应用程序中,需要知道是否有一些 dataActivity... 我知道有一个名为 TelephonyManager.DATA_ACTIVITY_NONE 的枚举。

我怎样才能得到这个值?

并且(作为奖励功能;))有什么方法可以获取当前的下载/上传速度?

这是我的代码:

public static int getDeviceNetwokActivity(Context context){
    TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

    return tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
                    | PhoneStateListener.LISTEN_DATA_ACTIVITY);
}

非常感谢!

【问题讨论】:

  • 我有root权限!

标签: android networking telephony


【解决方案1】:

我找到了这个代码的解决方案:

/**
 * Function that get the current device netwok activity
 * @param Context context - The context of application
 * @return int - [0,1,2,3,4,5,6]
 */
public static int getDeviceNetwokActivity(Context context){
    TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); // TelehponyManager
    return  manager.getDataActivity();
}

【讨论】:

    猜你喜欢
    • 2017-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-04
    • 1970-01-01
    相关资源
    最近更新 更多