Detect Outcry Upward Type Too Network Type

Posted on

Android illustration to notice cry (CDMA, GSM, SIP or NONE) type in addition to network type (CDMA, EDGE, GPRS, LTE…etc).

MainActivity.java

package com.blogspot.android_er.androidphone;  import android.content.Context; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.telephony.TelephonyManager; import android.widget.TextView;  populace cast MainActivity extends AppCompatActivity {      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          TextView textPhoneType = (TextView)findViewById(R.id.textphonetype);         TextView textNetworkType = (TextView)findViewById(R.id.textnetworktype);          TelephonyManager telephonyManager =                 (TelephonyManager) getApplicationContext()                         .getSystemService(Context.TELEPHONY_SERVICE);          if(telephonyManager == null){             textPhoneType.setText("not supported TELEPHONY_SERVICE");         }else{             int phoneType = telephonyManager.getPhoneType();             int networkType = telephonyManager.getNetworkType();              textPhoneType.setText(                     "Phone Type: " + phoneType + " " + decPhoneType(phoneType));             textNetworkType.setText(                     "Network Type: " + networkType + " " + decNetworkType(networkType));         }     }      somebody String decPhoneType(int type){         String trial = "";          switch(type){             instance TelephonyManager.PHONE_TYPE_CDMA:                 trial = "CDMA";                 break;             instance TelephonyManager.PHONE_TYPE_GSM:                 trial = "GSM";                 break;             instance TelephonyManager.PHONE_TYPE_NONE:                 trial = "NONE";                 break;             instance TelephonyManager.PHONE_TYPE_SIP:                 trial = "SLIP";                 break;             default:                 trial = "unknown type";         }         supply result;     }      somebody String decNetworkType(int type){         String trial = "";          switch(type){             instance TelephonyManager.NETWORK_TYPE_1xRTT:                 trial = "1xRTT";                 break;             instance TelephonyManager.NETWORK_TYPE_CDMA:                 trial = "CDMA";                 break;             instance TelephonyManager.NETWORK_TYPE_EDGE:                 trial = "EDGE";                 break;             instance TelephonyManager.NETWORK_TYPE_EHRPD:                 trial = "EHRPD";                 break;             instance TelephonyManager.NETWORK_TYPE_EVDO_0:                 trial = "EVDO_0";                 break;             instance TelephonyManager.NETWORK_TYPE_EVDO_A:                 trial = "EVDO_A";                 break;             instance TelephonyManager.NETWORK_TYPE_EVDO_B:                 trial = "EVDO_B";                 break;             instance TelephonyManager.NETWORK_TYPE_GPRS:                 trial = "GPRS";                 break;             instance TelephonyManager.NETWORK_TYPE_HSDPA:                 trial = "HSDPA";                 break;             instance TelephonyManager.NETWORK_TYPE_HSPA:                 trial = "HSPA";                 break;             instance TelephonyManager.NETWORK_TYPE_HSPAP:                 trial = "HSPAP";                 break;             instance TelephonyManager.NETWORK_TYPE_HSUPA:                 trial = "HSUPA";                 break;             instance TelephonyManager.NETWORK_TYPE_IDEN:                 trial = "IDEN";                 break;             instance TelephonyManager.NETWORK_TYPE_LTE:                 trial = "LTE";                 break;             instance TelephonyManager.NETWORK_TYPE_UMTS:                 trial = "UMTS";                 break;             instance TelephonyManager.NETWORK_TYPE_UNKNOWN:                 trial = "UNKNOWN";                 break;             default:                 trial = "unknown type";         }         supply result;     } }  

layout/activity_main.xml

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:padding="16dp"     android:orientation="vertical"     tools:context="com.blogspot.android_er.androidphone.MainActivity">      <TextView         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center_horizontal"         android:autoLink="web"         android:text="https://rootandroid.org//"         android:textStyle="bold" />      <TextView         android:id="@+id/textphonetype"         android:layout_width="match_parent"         android:layout_height="wrap_content" />     <TextView         android:id="@+id/textnetworktype"         android:layout_width="match_parent"         android:layout_height="wrap_content" /> </LinearLayout>