user368916
user368916

Reputation: 163

How to know sim type(2G, 3G) in android phone

I would like to know sim type(2G or 3G) inserted in android phone.

If I insert 2G only SIM card in android phone, which api used for knowing sim card type. In this case, I have to get return value as a 2G Sim.

best regards

Upvotes: 1

Views: 16630

Answers (2)

Vikas Patidar
Vikas Patidar

Reputation: 43349

Using android TelephonyManager you can get all the information related to network and phone.

Try this code snippet two know the type of the Network on your device:

package com.CheckNetworkType;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;

public class CheckNetworkType extends Activity
{
    private static final String  tag = "CheckNetworkType";

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        TelephonyManager tm =  (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);        
        if(tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_EDGE )
        {
            //  Network type is 2G
            Log.v(tag, "2G or GSM");
        }
        else 
        if(tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_CDMA)
        {
            // Network type is 2G
            Log.v(tag, "2G or CDMA");
        }
        else
        if(tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS)
        {
            // Network type is 3G
            Log.v(tag, "3G Network available.");
        }      
    }
}

the out put of the code will be as follows:

alt textalt text

Download the complete source code from here:

http://www.mediafire.com/file/yqkfk36k25ba7t4/CheckNetworkType.zip

Upvotes: 4

Sandy
Sandy

Reputation: 6353

Following link may give you some idea: http://www.krvarma.com/posts/android/using-android-telephonymanager/

Upvotes: 1

Related Questions