Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find Sim-card Network available or not?

Tags:

android

How to find Sim Network available or not?

I don't want to check internet connection..but I want to check simcard is availble but simcard network is available or not

It is possible to find sim available(Sim State) in simslot . And also mobile internet available or not . But please give me suggestion of how to find network of sim-card is available or not in android programmatically .

like image 377
Priya Lalani Avatar asked Dec 07 '25 10:12

Priya Lalani


1 Answers

Check out below code it will provide you signal strength of mobile network:

Define Variables:

TelephonyManager mTelephonyManager;
MyPhoneStateListener mPhoneStatelistener;   
int mSignalStrength = 0;

Then add this class to your code:

class MyPhoneStateListener extends PhoneStateListener {

     @Override
     public void onSignalStrengthsChanged(SignalStrength signalStrength) {
         super.onSignalStrengthsChanged(signalStrength);
         mSignalStrength = signalStrength.getGsmSignalStrength();
         mSignalStrength = (2 * mSignalStrength) - 113; // -> dBm           
     }
 }

and in your onCreate method use:

mPhoneStatelistener = new MyPhoneStateListener();
mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
mTelephonyManager.listen(mPhoneStatelistener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
like image 168
Mahesh Keshvala Avatar answered Dec 09 '25 23:12

Mahesh Keshvala



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!