
Each legitimate SIM slot in mobile phone has unique International Mobile Equipment Identity or IMEI number, e.g. if someone has two SIMs, then phone comes with two IMEI numbers.
At the time of registration of SIM (on every new device/ reboot/ restart) phone sends IMEI number to service providers so that service providers (SP) can match the IMEI & SIM. SPs save associated number data in their databases. Some SPs keep record of every IMEI associated with the mobile number.
But, that doesn’t mean one can hack your mobile number merely by knowing IMEI number.
IMEI number is useful when someone’s phone get stolen, or lost & found. SPs are having such data.
activity_main.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="match_parent" tools:context="com.androindian.raj.imei.MainActivity"> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/imei" android:text="IMEI"/> </LinearLayout> |
MainActivity.Java
Here also adding runtime permissions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
package com.androindian.raj.imei; import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.telephony.TelephonyManager; import android.view.View; import android.widget.Button; import android.widget.Toast; public class MainActivity extends AppCompatActivity { Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button = findViewById(R.id.imei); bt=findViewById(R.id.network); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { TelephonyManager tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); if (ActivityCompat.checkSelfPermission (MainActivity.this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } assert tel != null; String s1 = tel.getDeviceId(); Toast.makeText(getApplicationContext(), ""+s1,Toast.LENGTH_LONG).show(); } }); } } |