How can i get mobile network status?

First of all I am using android studio 1.5. I want to check GSM/GPRS network coverage? how can i get phone network status?

Answers


First of all you'll need these permissions

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

then after that where you want to check the Network status you should use this:

boolean isOnline= isNetworkStatusAvialable (getApplicationContext());

this will return if the mobile has Network available or not. hope this is all you need!

and just to let you know it is already answered on stackoverflow. you should really check if the question is there already or not!

Happy coding!


Need Your Help

How should I select which concrete implementation should be instantiated based on the user choice?

java reflection instantiation abstract-factory

I have an interface Fruit with two implementations Apple and Banana. I want to create a Fruit instance. The choice whether the concrete implementation should be an Apple or a Banana should be made ...

How do I debug a HTTP 502 error?

python http nginx

I have a Python Tornado server sitting behind a nginx frontend. Every now and then, but not every time, I get a 502 error. I look in the nginx access log and I see this: