{"id":84041,"date":"2021-08-27T09:00:54","date_gmt":"2021-08-27T03:30:54","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=84041"},"modified":"2024-08-05T22:07:40","modified_gmt":"2024-08-05T16:37:40","slug":"android-telephony","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/android-telephony\/","title":{"rendered":"Android Telephony and Telephony Manager"},"content":{"rendered":"<p>Did you ever think about how calls, SMS, MMS, etc., work on your device? Did you ever try to know or check your device\u2019s IMEI number? Using Android Telephony and Telephony Manager, you can quickly figure out how these things work. Along with this, it also provides you details of the network type, IMEI, SMS, etc.<\/p>\n<p>So, through this article, we will try to cover Android Telephony in detail and try to understand how you can implement it.<\/p>\n<h3>Android Telephony and Telephony Manager<\/h3>\n<p>Android Telephony is a package provided by Android to operate and get information about the network interfaces and device details. It has several interfaces and classes that are used to provide various functionalities.<\/p>\n<p>Android Telephony Manager is one such class that is present in the <strong>android.telephony<\/strong> package. It provides you with several methods to get the network or telephony information and know its current state. Along with this, you also get the subscriber information using the Telephony Manager methods.<\/p>\n<p>To access the Telephony Manager in your programming, you can simply import the <strong>android.telphony.TelephonyManager<\/strong> class.<\/p>\n<p>After that, you need to use the <strong>getSystemService()<\/strong> to create the TelephonyManager object, and then you can use it to get system information.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">val telephonyManager = getSystemService(Context.TELEPHONY_SERVICE) as\r\n                TelephonyManager<\/pre>\n<p>Typical applications that use Telephony and Telephony Manager are your SIM Toolkit, Dialer, IMEI Checker, Browser, etc.<\/p>\n<h3>Architecture of Android Telephony<\/h3>\n<p>The architecture of Android Telephony is subdivided into four layers. These four layers help it interact with users and low-level devices like your network adapters.<\/p>\n<p>The four layers involved in the Android Telephony are described below:<\/p>\n<h4>1. Communication Processor<\/h4>\n<p>The communication processor in an Android device is responsible for handling communication tasks and collecting data from various peripherals. It takes inputs from devices such as sensors, GPS modules, and Wi-Fi chips, processes this information, and distributes it across the communication network. This processor ensures seamless connectivity and efficient data transfer between different components, making it crucial for maintaining network performance and reliability.<\/p>\n<h4>2. Radio Interface Layer (RIL)<\/h4>\n<p>The Radio Interface Layer is an interface through which the hardware components interact with the frameworks. It\u2019s a bridge with protocols for the Telephony services and is therefore known as protocol stack for Telephone. The RIL consist of two components that are as follows:<\/p>\n<p><strong>a. RIL Daemon &#8211;<\/strong> The RIL Daemon (rild) is a crucial background process that starts up immediately when your device powers on. It is responsible for initializing the Radio Interface Layer and reading system properties to configure telephony services. The RIL Daemon ensures that the necessary libraries and resources are loaded and ready, allowing the Vendor RIL to function properly and enabling the device to communicate with the network.<\/p>\n<p><strong>b. Vendor RIL &#8211;<\/strong> The Vendor RIL is a library specific to each network modem and is tailored to the hardware capabilities and protocols of the device&#8217;s modem. This library translates generic telephony requests from the Android telephony framework into specific commands that the modem can understand and execute. The Vendor RIL ensures compatibility and optimal performance between the Android operating system and the network hardware, facilitating tasks like call handling, SMS, and data connectivity.<\/p>\n<h4>3. Framework Services<\/h4>\n<p>Framework services consist of various packages and assists the Telephony Manager in directing all the application API requests to RIL. The framework services start immediately when the device boots up.<\/p>\n<h4>4. Application<\/h4>\n<p>Applications are the last layer of the Telephony architecture. The applications are used directly by the user to interact with the Telephony Services. Some of the standard applications are IMEI checker, Dialer, SIM Toolkit, Browser, etc.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/Android-telephony-framework-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84330\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/Android-telephony-framework-1.jpg\" alt=\"Android telephony framework\" width=\"581\" height=\"1088\" \/><\/a><\/p>\n<h3>Implementation of Android Telephony<\/h3>\n<p>Now, let\u2019s see how you can implement the telephony and get information about your device and subscribers. Follow the below steps:<\/p>\n<p><strong>1:<\/strong> Run your Android Studio and create a new project.<\/p>\n<p><strong>2:<\/strong> Select Empty Activity, name your project and choose API level 22 and proceed.<\/p>\n<p><strong>3:<\/strong> After the Gradle build is finished, open your AndroidManifest.xml file and add the permissions below.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;uses-permission android:name=\"android.permission.READ_PHONE_STATE\" \/&gt;\r\n<\/pre>\n<p>After adding the above permissions, your AndroidManifest.xml file would appear as follows.<\/p>\n<p><strong>Code: AndroidManifest.xml<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;manifest xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    package=\"com.techvidvan.techvidvanandroidtelephony\"&gt;\r\n\r\n    &lt;uses-permission android:name=\"android.permission.READ_PHONE_STATE\" \/&gt;\r\n\r\n    &lt;application\r\n        android:allowBackup=\"true\"\r\n        android:icon=\"@mipmap\/ic_launcher\"\r\n        android:label=\"@string\/app_name\"\r\n        android:roundIcon=\"@mipmap\/ic_launcher_round\"\r\n        android:supportsRtl=\"true\"\r\n        android:theme=\"@style\/Theme.TechVidvanAndroidTelephony\"&gt;\r\n        &lt;activity android:name=\".MainActivity\"&gt;\r\n            &lt;intent-filter&gt;\r\n                &lt;action android:name=\"android.intent.action.MAIN\" \/&gt;\r\n\r\n                &lt;category android:name=\"android.intent.category.LAUNCHER\" \/&gt;\r\n            &lt;\/intent-filter&gt;\r\n        &lt;\/activity&gt;\r\n    &lt;\/application&gt;\r\n\r\n&lt;\/manifest&gt;<\/pre>\n<p><strong>4:<\/strong> Now, open your activity_main.xml and paste the below code there.<\/p>\n<p><strong>Code: activity_main.xml<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:orientation=\"vertical\"\r\n    android:layout_height=\"match_parent\"\r\n    tools:context=\".MainActivity\"&gt;\r\n\r\n    &lt;TextView\r\n        android:id=\"@+id\/title\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:text=\"TechVidvan\"\r\n        android:textSize=\"30sp\"\r\n        android:textColor=\"#4CAF50\"\r\n        android:gravity=\"center\"\r\n        android:textStyle=\"bold\"\r\n        android:layout_marginTop=\"20dp\"\r\n        android:layout_marginBottom=\"20dp\"\/&gt;\r\n\r\n    &lt;TextView\r\n        android:id=\"@+id\/telephonyResult\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:textSize=\"30sp\"\r\n        android:textColor=\"@color\/black\"\r\n        android:gravity=\"center\"\r\n        android:layout_marginTop=\"20dp\"\r\n        android:layout_marginBottom=\"20dp\"\/&gt;\r\n\r\n&lt;\/LinearLayout&gt;\r\n<\/pre>\n<p><strong>5:<\/strong> Finally, copy the below code and paste it into your MainActivity.kt file.<\/p>\n<p><strong>Code: MainActivity.kt<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.techvidvan.techvidvanandroidtelephony\r\n\r\nimport android.content.Context\r\nimport android.os.Bundle\r\nimport android.telephony.TelephonyManager\r\nimport android.widget.TextView\r\nimport androidx.appcompat.app.AppCompatActivity\r\n\r\nclass MainActivity : AppCompatActivity()\r\n{\r\n    \/\/declaring variables\r\n    lateinit var telephonyResult:TextView\r\n\r\n    override fun onCreate(savedInstanceState: Bundle?)\r\n    {\r\n        super.onCreate(savedInstanceState)\r\n        setContentView(R.layout.activity_main)\r\n\r\n        \/\/binding variables with text view\r\n        telephonyResult = findViewById(R.id.telephonyResult)\r\n\r\n        \/\/creating a Telephony Manager object\r\n        val telephonyManager = getSystemService(Context.TELEPHONY_SERVICE) as\r\n                TelephonyManager\r\n\r\n\r\n        var result = \"\";\r\n\r\n        \/\/fetching information of your device using telephony manager\r\n        \/\/and storing them in result\r\n        result = result + \"\\nCountry ISO = \"+ telephonyManager.networkCountryIso\r\n        result = result+ \"\\nSIM Country ISO = \"+ telephonyManager.simCountryIso\r\n        result = result+ \"\\nRoaming Enabled = \"+ telephonyManager.isNetworkRoaming\r\n\r\n        \/\/displaying our results\r\n        telephonyResult.text = result\r\n    }\r\n}<\/pre>\n<p>Now run your application and observe the device details which you receive.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/App_Output-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84331\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/App_Output-1.jpg\" alt=\"Android Telephony Manager\" width=\"1080\" height=\"2280\" \/><\/a><\/p>\n<h3>Summary<\/h3>\n<p>So, through this article, you came across Android Telephony and Telephony Manager. Using these two, you can quickly get information about your device, network, and subscriber. You came across the architecture and the four layers present in it. Finally, you saw an implementation of the Android Telephony by displaying your device details.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Did you ever think about how calls, SMS, MMS, etc., work on your device? Did you ever try to know or check your device\u2019s IMEI number? Using Android Telephony and Telephony Manager, you can&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":84329,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2791],"tags":[4123,4124],"class_list":["post-84041","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","tag-android-telephony","tag-android-telephony-manager"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Android Telephony and Telephony Manager - TechVidvan<\/title>\n<meta name=\"description\" content=\"Learn about Android Telephony &amp; Telephony Manager with implementation. See the architecture and the four layers present in it.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/android-telephony\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android Telephony and Telephony Manager - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Learn about Android Telephony &amp; Telephony Manager with implementation. See the architecture and the four layers present in it.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/android-telephony\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-27T03:30:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-05T16:37:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Android_Telephony.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android Telephony and Telephony Manager - TechVidvan","description":"Learn about Android Telephony & Telephony Manager with implementation. See the architecture and the four layers present in it.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/android-telephony\/","og_locale":"en_US","og_type":"article","og_title":"Android Telephony and Telephony Manager - TechVidvan","og_description":"Learn about Android Telephony & Telephony Manager with implementation. See the architecture and the four layers present in it.","og_url":"https:\/\/techvidvan.com\/tutorials\/android-telephony\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-08-27T03:30:54+00:00","article_modified_time":"2024-08-05T16:37:40+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Android_Telephony.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/android-telephony\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-telephony\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Android Telephony and Telephony Manager","datePublished":"2021-08-27T03:30:54+00:00","dateModified":"2024-08-05T16:37:40+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-telephony\/"},"wordCount":771,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-telephony\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Android_Telephony.jpg","keywords":["Android Telephony","Android Telephony Manager"],"articleSection":["Android Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/android-telephony\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/android-telephony\/","url":"https:\/\/techvidvan.com\/tutorials\/android-telephony\/","name":"Android Telephony and Telephony Manager - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-telephony\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-telephony\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Android_Telephony.jpg","datePublished":"2021-08-27T03:30:54+00:00","dateModified":"2024-08-05T16:37:40+00:00","description":"Learn about Android Telephony & Telephony Manager with implementation. See the architecture and the four layers present in it.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/android-telephony\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/android-telephony\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/android-telephony\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Android_Telephony.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/Android_Telephony.jpg","width":1200,"height":628,"caption":"Android Telephony"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/android-telephony\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Android Telephony and Telephony Manager"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/84041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=84041"}],"version-history":[{"count":2,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/84041\/revisions"}],"predecessor-version":[{"id":447614,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/84041\/revisions\/447614"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/84329"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=84041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=84041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=84041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}