title: Kotlin : TelephonyManager.getImei() Call requires permission which may be rejected by user
body: <p>I'am developping an android app with Kotlin, i use the api 28.
  I want to get the deviceId number.At the begining i use TelephonyManager.deviceId, after some research,i found that it's deprecated.<br>
  I found as solution, replace deviceId by getImei()
  The following an excerpt from my code:</p>
  
  <pre><code> val telephonyManager = getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
          if (telephonyManager != null) {
  
              val androidID = Settings.Secure.getString(this.contentResolver, Settings.Secure.ANDROID_ID)
              if (androidID != null) {
                  Utility().DEVICE_ID = androidID
                  Utility().setDataBykeyValue(applicationContext, AppController.SHAIRD_PREF_DEVICE_ID, androidID)
              } else {
                  val devId = if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.O) telephonyManager.getImei()
                   else telephonyManager.getDeviceId()
                  Utility().DEVICE_ID  = devId
                  Utility().setDataBykeyValue(applicationContext, AppController.SHAIRD_PREF_DEVICE_ID, devId)
              }
              Utility().CARRIER = telephonyManager.simOperatorName
  
          }
  </code></pre>
  
  <p>Also i add this permission to my AndroidManifest.xml :</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;
  </code></pre>
  
  <p>the "telephonyManager.getImei()" is underline with a red line, and the following msg appear :</p>
  
  <blockquote>
    <p>Call requires permission which may be rejected by user: code should
    explicitly check to see if permission is available (with
    checkPermission) or explicitly handle a potential</p>
  </blockquote>
  
  <p>I want to know what's the problem and how can i correct it </p>