What do you actually need to accomplish? Normally you would try to reach a 
well known host like 8.8.8.8 and if that succeeds you're connected (on 
whatever network connection). 

On Monday, January 27, 2014 4:06:58 AM UTC-5, 12169 wrote:
>
> Hi,
>
> is there any way to check ,mobile data on/off in the settings.
>
> On Sunday, January 26, 2014 11:22:19 PM UTC+5:30, 12169 wrote:
>>
>> Hi,
>> I want to check whether mobile data is on/off, and for this I use the 
>> below code
>>
>> ConnectivityManager cm = (ConnectivityManager) context
>>             .getSystemService(Context.CONNECTIVITY_SERVICE);Class cmClass = 
>> Class.forName(cm.getClass().getName());
>>         Method method = cmClass.getDeclaredMethod("getMobileDataEnabled");
>>         method.setAccessible(true); // Make the method callable
>>         // get the setting for "mobile data"
>>         mobileDataEnabled = (Boolean) method.invoke(cm);
>>
>>
>> However, this code does not work on some devices, and throws an exception 
>> that no such method exists. I have found it is not working in Android 4.1.x. 
>> Why is it throwing this execption, and how can I fix it?
>>
>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to