Search code examples
androidtelephony

Check hardware support for mobile data Android


I have an Android issue. My application should be aware if there is a possibility for mobile data connection. Right now I have only found answers about checking if current network IS 3g.

But my function should know if there is a hardware possibility of connecting to mobile network.

So if you take an android device with SIM slot but without SIM card,function should return TRUE


Solution

  • There's a few ways to do this:

    Android Manifest:

    Set a uses-features tag in the manifiest (this should be used only if one wants to limit his app only for telephony enabled devices):

    <uses-feature name="android.hardware.telephony" required="true"/>
    

    Check from the source code:

    PackageManager mgr = context.getPackageManager();
    boolean hasTelephony = mgr.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
    

    From the uses-features page, telephony includes:

    The application uses telephony features on the device, such as telephony radio with data communication services.