1.获取系统设置里面的响亮和振动是否使能
Settings.System.getInt(Context mContext, "vibrate_when_ringing",0);
2.获取系统当前网络制式
int netWorkMode;
try {
netWorkMode = Settings.Secure.getInt(MainActivity.this.getContentResolver(), "preferred_network_mode");
System.err.println(netWorkMode);
} catch (SettingNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
3.获取移动数据开关状态
public static boolean getMobileDataStatus(Context context)
{
String methodName = "getMobileDataEnabled";
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
Class cmClass = mConnectivityManager.getClass();
Boolean isOpen = null;
try
{
Method method = cmClass.getMethod(methodName, null);
isOpen = (Boolean) method.invoke(mConnectivityManager, null);
}
catch (Exception e)
{
e.printStackTrace();
}
return isOpen;
}
网友评论